Skip to main content

Command-line argument parsing for Python, without the effort

Project description

Join the chat at https://gitter.im/epsy/clize https://travis-ci.org/epsy/clize.svg?branch=master https://coveralls.io/repos/epsy/clize/badge.svg?branch=master

Clize procedurally turns your functions into convenient command-line interfaces.

For instance:

from clize import run

def hello_world(name=None, *, no_capitalize=False):
    """Greets the world or the given name.

    name: If specified, only greet this person.

    no_capitalize: Don't capitalize the given name.
    """
    if name:
        if not no_capitalize:
            name = name.title()
        return 'Hello {0}!'.format(name)
    return 'Hello world!'

if __name__ == '__main__':
    run(hello_world)

The python code above can now be used on the command-line as follows:

$ pip install clize
$ python3 hello.py --help
    Usage: hello.py [OPTIONS] name

    Greets the world or the given name.

    Positional arguments:
      name   If specified, only greet this person.

    Options:
      --no-capitalize   Don't capitalize the given name.

    Other actions:
      -h, --help   Show the help
$ python3 hello.py
Hello world!
$ python3 hello.py john
Hello John!
$ python3 hello.py dave --no-capitalize
Hello dave!

You can find the documentation at: http://clize.readthedocs.io/

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

clize-3.1.0.tar.gz (50.6 kB view details)

Uploaded Source

Built Distribution

clize-3.1.0-py2.py3-none-any.whl (56.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file clize-3.1.0.tar.gz.

File metadata

  • Download URL: clize-3.1.0.tar.gz
  • Upload date:
  • Size: 50.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for clize-3.1.0.tar.gz
Algorithm Hash digest
SHA256 633decd514f12c82eb28203cbb64d0577c5ef1cd30a4ff66f8a5d989a803ad77
MD5 c2792b217903907d6a0eed075cb9e01c
BLAKE2b-256 060cbcd4769c333096f584b5d83b2a8e2e36a57e8ba1fc12a63fc9b27eebeee8

See more details on using hashes here.

File details

Details for the file clize-3.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for clize-3.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2b112f62b8ca7028ff9b8aea0108496b893ce0b4eba17a462005bb02095d7ec2
MD5 52e6a0723668479778a7177f9501710a
BLAKE2b-256 f892709053980d6b56cf4ea81c89f425d99f22d1200fea9db4691681cf5538e2

See more details on using hashes here.

Supported by

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