Automatic command-line argument parsing converted from your function parameters
Project description
Clize procedurally turns your functions into convenient command-line interfaces.
For instance:
from clize import run
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
$ 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 at: http://clize.readthedocs.io/
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-4.0a1.tar.gz
(62.4 kB
view hashes)
Built Distribution
clize-4.0a1-py2.py3-none-any.whl
(68.1 kB
view hashes)
Close
Hashes for clize-4.0a1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 815f0d9388c8edca81d3def06b45d33dfb8465c4328c1aeaabb10caeac8058e1 |
|
MD5 | 60fcc75fa127660b6c539b13f6864e82 |
|
BLAKE2b-256 | b3364efd68cd75dd66d0160d5ac7dbdf9e29ca5dd21cf9fbce70497d27ef1658 |