clize: Turn functions into command-line interfacesΒΆ

Clize is an argument parser for Python. You can use Clize as an alternative to argparse if you want an even easier way to create command-line interfaces.

With Clize, you can:

  • Create command-line interfaces by creating functions and passing them to
  • Enjoy a CLI automatically created from your functions’ parameters.
  • Bring your users familiar --help messages generated from your docstrings.
  • Reuse functionality across multiple commands using decorators.
  • Extend Clize with new parameter behavior.

Here’s an example:

from clize import run

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

    :param name: If specified, only greet this person.
    :param 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 takes the function and automatically produces a command-line interface for it:

$ python3 -m pip install --user clize
$ python3 examples/ --help
Usage: examples/ [OPTIONS] [name]

Greets the world or the given name.

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

  --no-capitalize   Don't capitalize the give name.

Other actions:
  -h, --help        Show the help
$ python
Hello world!
$ python john
Hello John!
$ python dave --no-capitalize
Hello dave!

While we use Python 3 syntax in this example, Clize is fully compatible with Python 2.7.


Here is the full table of contents:

The user reference lists all capabilities of each kind of parameter. The API reference comes in handy if you’re extending clize.

Information on how Clize is organized as a project.