Skip to main content

Utilities for building CLI scripts in Python

Project description

Example usage

You can create your CLI script like this:

from clitools import CliApp

cli = CliApp()


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


if __name__ == '__main__':
    cli.run()

and then run it right away!

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

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

positional arguments:
  {hello}     sub-commands
    hello

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

% python sample_app.py hello
Hello, world

% python sample_app.py hello --name=Python
Hello, Python

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

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

% python sample_app.py 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 :)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CliTools-0.4b1.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file CliTools-0.4b1.tar.gz.

File metadata

  • Download URL: CliTools-0.4b1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for CliTools-0.4b1.tar.gz
Algorithm Hash digest
SHA256 7b1b18ebf36704bf73e234ba5880995b897674a80755496103900b1f268a775b
MD5 6f9b7f3da25bc10de90540935fccdebf
BLAKE2b-256 b4a516f9e79ec5bcdc730c544bb89fc77fd21b5e172635fb9f00346830573c9c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page