Skip to content
This repository

Clize: Command-line argument parsing for Python, without the effort

branch: master

Parser improvements:

* Flag parameters' short argument form can now be chained correctly.
* FlagParameter's initializer accepts a custom value to replace False
* FlagParameters now accept --flag=0 and similar as negation.
* Added tests for Parameter.LAST_OPTION
* Parameter.read_argument is now called with (bound_arguments, position)
* Its return value is no longer evaluated, so it is expected to change
  attributes of bound_arguments when needed instead.
* Removed all instances of read_one_argument
latest commit 8203ccf64a
Yann Kaiser authored March 31, 2014
Octocat-spinner-32 clize Parser improvements: March 31, 2014
Octocat-spinner-32 docs Added upgrade instructions for users of extra and make_flag. January 11, 2014
Octocat-spinner-32 examples Reworked the decorator example. December 29, 2013
Octocat-spinner-32 .bzrignore Complete rewrite, compatibility kept. November 11, 2013
Octocat-spinner-32 .coveragerc Complete rewrite, compatibility kept. November 11, 2013
Octocat-spinner-32 .gitignore Finishing touches to ksamuel's patch: February 24, 2012
Octocat-spinner-32 COPYING Add licensing info to each file November 11, 2013
Octocat-spinner-32 MANIFEST.in Version bump April 12, 2012
Octocat-spinner-32 README.rst update the readme file November 11, 2013
Octocat-spinner-32 setup.py Restored 2.6-2.7 compatibility. December 14, 2013
README.rst

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

from sigtools.modifiers import kwoargs
from clize import run

@kwoargs('no_capitalize')
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)
$ pip install clize
$ python 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
$ python hello.py
Hello world!
$ python hello.py john
Hello John!
$ python hello.py --no-capitalize
Hello john!

You can find the documentation at: http://clize.readthedocs.org/en/latest/

Something went wrong with that request. Please try again.