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
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
clap_python-0.2.3.tar.gz
(34.9 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
File details
Details for the file clap_python-0.2.3.tar.gz.
File metadata
- Download URL: clap_python-0.2.3.tar.gz
- Upload date:
- Size: 34.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eef98a08ea31f0d09b7a8d9eeaf0790232e75472633ef84da1e77a0a51aaa4e6
|
|
| MD5 |
627e3d650958f68342304ca21b14ef43
|
|
| BLAKE2b-256 |
3d12705d6b83b501429a0251b5b65b2159366609da81bf1f3cd78377b68615ad
|
File details
Details for the file clap_python-0.2.3-py3-none-any.whl.
File metadata
- Download URL: clap_python-0.2.3-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fb379b98ba7b5396557745a61d618690a5aea826947971b623fc952edf45e95
|
|
| MD5 |
a8d9a00c9ff47cdbc618792498899488
|
|
| BLAKE2b-256 |
7ef401ba90b0087c359355eab34c8ccef5756d00d4ccc318e0ff83a1108524f4
|