Skip to main content

Rust Clap inspired command line argument parser.

Project description

clap-python

Command Line Argument Parser for Python

License PyPi

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.2.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

clap_python-0.1.2-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file clap_python-0.1.2.tar.gz.

File metadata

  • Download URL: clap_python-0.1.2.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for clap_python-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d0caa11fd87a1c98e4def6caae961c55ac8cd767c1fed7a363d026e68ae4d230
MD5 36dae9db629c6206c8bbb8b86f6c12fb
BLAKE2b-256 f2e2e9c8d4a87d5da9ecadb32f52d69451dc2ef036c714c5c26323b653288f98

See more details on using hashes here.

File details

Details for the file clap_python-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: clap_python-0.1.2-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

Hashes for clap_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f9ae68d6162fd87b3cdf71faa0bbc353b7779cac6b46304c87338c0b2a2d126c
MD5 7d6d207c9c62da0d1534f9688c35b33d
BLAKE2b-256 23999d2be9e06e8b8d31297600a64c3598e4a083112456c1825880f3331b66ff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page