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.4.tar.gz
(37.2 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.4.tar.gz.
File metadata
- Download URL: clap_python-0.2.4.tar.gz
- Upload date:
- Size: 37.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8be0b9269009267aa333f73f5c8b957a1ad2f3267f2b939233552dd5e6afbde
|
|
| MD5 |
cf8523dfc8674ffd265b9216d9542b24
|
|
| BLAKE2b-256 |
7ac2e371c898f94d17764b9e9baf0eb7ef4b50590b01853726a42a9e1a179bf5
|
File details
Details for the file clap_python-0.2.4-py3-none-any.whl.
File metadata
- Download URL: clap_python-0.2.4-py3-none-any.whl
- Upload date:
- Size: 24.5 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 |
79bb93ebb387256414e2af8a6932defa53cd1514ccd19fd979e4fa74960f986b
|
|
| MD5 |
27a345ab34978734efb68ad7bd92b9ee
|
|
| BLAKE2b-256 |
16844184a25859680c42b3b5f7c55929558a5dc3ad466db7e14df3cde49702eb
|