Rust Clap inspired command line argument parser.
Project description
clap-python
Command Line Argument Parser for Python
Licensed under Apache 2.0.
About
A full-featured, fast Command Line Argument Parser for Python
For more details, see:
Quick Start
pip install clap_python
from clap_python import App, Arg
app = (
App()
.version("0.1.0") # Version of the app.
.arg_required_else_help(True) # If no args passed show help message.
.arg(Arg("--name", "-n").help("Name of the person to greet").required(True))
.arg(
Arg("--count", "-c")
.help("Number of times to greet")
.default(1)
.value_parser(int) # tell the parser to cast arg to int.
)
)
if __name__ == "__main__":
args = app.parse_args()
for _ in range(args["count"]):
print(f"Hello {args['name']}!")
Positionals
from clap_python import App, Arg
if __name__ == "__main__":
args = App().arg(Arg("names").multiple_values(True)).parse_args()
print(f"names: {args['names']}")
Autocomplete
from clap_python import App, Arg
from clap_python.complete import autocomplete
app = App().arg(Arg("-c")).arg(Arg("--files").multiple_values(True))
autocomplete(app) # Enable autocompletion
args = app.parse_args() # Parse arguments
print(args)
You can read more at docs
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clap_python-0.2.1.tar.gz
(34.7 kB
view details)
Built Distribution
File details
Details for the file clap_python-0.2.1.tar.gz
.
File metadata
- Download URL: clap_python-0.2.1.tar.gz
- Upload date:
- Size: 34.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dc15596475d3a479d9dc694a27eaf592f065cd04a6b377f7d00ea431fa0c9df |
|
MD5 | f759099e5be01c10172a1823d36cb1a0 |
|
BLAKE2b-256 | e8dabdd9ee41b57a8ff577ba9700aff3e6c54bba1cb30c7c22cb886d2a6cd327 |
File details
Details for the file clap_python-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: clap_python-0.2.1-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 354e8e3cc514ea094a63f8d3a09267c9fd45ffe27b540077284f984e1a5fd765 |
|
MD5 | fed1b8b24672858c57ee7b64aeaad5c1 |
|
BLAKE2b-256 | 6e22a683e2972f2ae27bd3fef6d4a3fd4d55c6d36da7d49581adc3877f4f6d96 |