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/
Release files for clize 3.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clize-3.1.0.tar.gz | 50.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clize-3.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 106.6 kB
Release files / clize-3.1.0.tar.gz
| Download URL | clize-3.1.0.tar.gz |
|---|---|
| Size | 50.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
633decd514f12c82eb28203cbb64d0577c5ef1cd30a4ff66f8a5d989a803ad77
|
|
BLAKE2b-256 checksum How to use checksums |
060cbcd4769c333096f584b5d83b2a8e2e36a57e8ba1fc12a63fc9b27eebeee8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / clize-3.1.0-py2.py3-none-any.whl
| Download URL | clize-3.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 56.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2b112f62b8ca7028ff9b8aea0108496b893ce0b4eba17a462005bb02095d7ec2
|
|
BLAKE2b-256 checksum How to use checksums |
f892709053980d6b56cf4ea81c89f425d99f22d1200fea9db4691681cf5538e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |