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']}")

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


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

Uploaded Source

Built Distribution

clap_python-0.2.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clap_python-0.2.0.tar.gz
  • Upload date:
  • Size: 34.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.2.0.tar.gz
Algorithm Hash digest
SHA256 a72befa2ca90b118602a54a87615cd0662855d0dc4758d6941db01921b027cce
MD5 da6eea1904348b820336440a1133e686
BLAKE2b-256 39c284a6da02776b3dc5261d0d21f3dc640bc444853529ed94d236905ea383bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clap_python-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.9 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 698352294820cf7adbfd541f3003c0cce338193256e240817d29014cf2798afd
MD5 4a5664f3b5bdf9783cd6f1bc52dee661
BLAKE2b-256 fa103d7d61860aee16f002ce56167c1bb52e122643d67e33c3428a3bcdbd79af

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