Rust Clap inspired command line argument parser.
Project description
clap-py
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']}")
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.1.1.tar.gz
(26.7 kB
view details)
Built Distribution
File details
Details for the file clap_python-0.1.1.tar.gz
.
File metadata
- Download URL: clap_python-0.1.1.tar.gz
- Upload date:
- Size: 26.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 | f23f70b666828197497beb515066fb7b7a15fabf5d007e9379c215d9c626a4df |
|
MD5 | 12803206b697dc3ca513ec45fa1f4964 |
|
BLAKE2b-256 | e5533229e448419e0675df544e70c7df71792da2b38e617dc803d8d66fd5ebe2 |
File details
Details for the file clap_python-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: clap_python-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.3 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 | b1c38bbcdc594edf03603a0b6844c76107e5b6c6b7486741f20cc3608c8e2725 |
|
MD5 | cec80696008e53e39c1a2791468afdf1 |
|
BLAKE2b-256 | e52efddb1ac09b6a5a3e9cd4feb7058114b47814834ce50db4cf6598ba811283 |