Command-line argument parsing for Python, without the effort
Project description
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 dave --no-capitalize
Hello dave!
You can find the documentation at: http://clize.readthedocs.org/
Project details
Release history Release notifications | RSS feed
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.1b1.tar.gz
(48.1 kB
view hashes)
Built Distribution
clize-3.1b1-py2.py3-none-any.whl
(54.8 kB
view hashes)
Close
Hashes for clize-3.1b1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4406dec1c440ac18a242ae03ada4b6d72a95c901ba1035564a858d92fc11abc |
|
MD5 | 373d32695e77beb7227794731a0fd4f0 |
|
BLAKE2b-256 | 03dc189c8b55da5503d83debf0e5493eace4a606a808b13c5366f7f403292bac |