Skip to content
/ clize Public
forked from epsy/clize

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

License

Notifications You must be signed in to change notification settings

edk0/clize

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

For instance:

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)

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

$ 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/

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%