Utilities for building CLI scripts in Python

pip install CliTools==0.4b1


Cli Tools

Tools for quickly creating Command Line Interface scripts with Python.

Build Status Coverage Status PyPi version


All the package documentation is hosted on GitHub pages:

Example usage

You can create your CLI script like this:

from clitools import CliApp

cli = CliApp()

def hello(name='world', bye=False):
    greet = 'Bye' if bye else 'Hello'
    print("{0}, {1}".format(greet, name))

if __name__ == '__main__':

and then run it right away!

% python
usage: cli-app [-h] {hello} ...
cli-app: error: too few arguments
>>> exited 2

% python --help
usage: cli-app [-h] {hello} ...

positional arguments:
  {hello}     sub-commands

optional arguments:
  -h, --help  show this help message and exit

% python hello
Hello, world

% python hello --name=Python
Hello, Python

% python hello --help
usage: cli-app hello [-h] [--bye] [--name NAME]

optional arguments:
  -h, --help   show this help message and exit
  --name NAME

% python hello --bye --name=Spam
Bye, Spam

..super-cool, isn't it?

What's the difference with other libraries, such as Cliff?

Cliff is meant for building complex, fully-featured CLI applications. CliTools just acts as a "bridge" to quickly expose a Python function as a script in the "most obvious" way, without need for extensibility or support for more complex use cases.

The main goal is to provide something you can quickly use without having to continuously refer to the documentation :)

Bitdeli Badge