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.0.tar.gz
(47.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
clize-3.0-py2.py3-none-any.whl
(53.7 kB
view details)
File details
Details for the file clize-3.0.tar.gz.
File metadata
- Download URL: clize-3.0.tar.gz
- Upload date:
- Size: 47.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
158e3251106fa9c2dfe414a3fea0c07eecb15b5be6ddf68a7cf73402081c79f6
|
|
| MD5 |
bf0f07d1d2ac913c773c85c66d6b20c4
|
|
| BLAKE2b-256 |
61d4a5ad1938350db1b8c0fdba41d4d4f715d02bed10eca2dab623527f2ded78
|
File details
Details for the file clize-3.0-py2.py3-none-any.whl.
File metadata
- Download URL: clize-3.0-py2.py3-none-any.whl
- Upload date:
- Size: 53.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10b90afc86c27dc7f7465e087fbeebebbf36c5d8efa28b7c8bda5c2af2ae7551
|
|
| MD5 |
e95ebcb064e31a453a6f0ecca04388bf
|
|
| BLAKE2b-256 |
f1f898abd0d47c62af53d4616ca82805f413ab1a4e381e037a4727d0b568e6a0
|