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

Uploaded Source

Built Distribution

clap_python-0.1.3-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clap_python-0.1.3.tar.gz
  • Upload date:
  • Size: 28.2 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.3.tar.gz
Algorithm Hash digest
SHA256 a211c6cff931a9b5238630173f12e2009e16c84dd3e62397247f2ee63850093d
MD5 f8171697ae736ca7f033f0f55d0562b7
BLAKE2b-256 c03f3bf90c901af0851a2057b342f401b2110100dff6ac6a3732ff993ff4c761

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clap_python-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 28b62bafee8895a2eade9d15b914678f09ff01cd6b400528d14af6675a6028ef
MD5 5e10ef2088db1f5add93310bff3955b1
BLAKE2b-256 8c176759a43f69303c9e2e7fd30d10a88790cb17cf0347b8e9e17b7e1994b769

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