Need help with clize?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

epsy
441 Stars 24 Forks Other 403 Commits 25 Opened issues

Description

CLIze: Turn Python functions into command-line interfaces

Services available

!
?

Need anything else?

Contributors list

# 240,921
coveral...
HTML
CSS
argumen...
381 commits
# 46,610
fish-sh...
rabbitm...
s3
ec2
2 commits
# 592,739
Python
gist
GitHub
Git
2 commits
# 412,866
pandas
SQLite
tsv
hdf5
1 commit
# 292,306
OCaml
opam
Git
seccomp
1 commit
# 141,717
systemv...
Shell
asic
Electro...
1 commit
# 3,203
imagema...
sass-fr...
splash
pipelin...
1 commit
# 65,608
postgre...
python-...
jython
nagios
1 commit
# 264,704
i3statu...
i3bar
python3
Zsh
1 commit
# 34,990
contrib...
micropy...
obs-stu...
Twitch
1 commit

Clize


.. image:: https://readthedocs.org/projects/clize/badge/?version=stable :target: http://clize.readthedocs.io/en/stable/?badge=stable :alt: Documentation Status .. image:: https://readthedocs.org/projects/clize/badge/?version=latest :target: http://clize.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://badges.gitter.im/Join%20Chat.svg :alt: Join the chat at https://gitter.im/epsy/clize :target: https://gitter.im/epsy/clize?utmsource=badge&utmmedium=badge&utmcampaign=pr-badge&utmcontent=badge .. image:: https://travis-ci.org/epsy/clize.svg?branch=master :target: https://travis-ci.org/epsy/clize .. image:: https://coveralls.io/repos/epsy/clize/badge.svg?branch=master :target: https://coveralls.io/r/epsy/clize?branch=master

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
    clize.run
    .
  • 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:

.. code-block:: python

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(hello_world)

Python 2.7 is supported through

decorators
_.

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

.. code-block:: console

$ 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 and tutorials at http://clize.readthedocs.io/

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.