Skip to main content

cli-args

Do you belong to those who have to look up the calls you have to make to argparse? And are you longing for a way to just import the parsed arguments as you would import sys.argv? Then cli-args is the way to go!

cli-args is a Python library for an easier parsing of command line arguments. It wraps the popular argparse to allow importing parsed arguments from anywhere in the code. One of the key features is the way you define what arguments you accept. By providing a dictionary - that also can be read from a JSON file! - you can easily set all available command line arguments at one specific, easy-to-find place.

Get it!

pip install cli-args

Use it!

demo.py

import cli_args


# or: cli_args.from_file('path/to/schema.json')
cli_args.from_schema({
    "description": "Process some integers.",
    "arguments": [
        {
            "short": "a",
            "long": "integer_a",
            "var": "NUMBER",
            "help": "The first integer",
            "default": 0,
            "type": "int"
        },
        {
            "short": "b",
            "long": "integer_b",
            "var": "NUMBER",
            "help": "The second integer",
            "default": "0",
            "type": "int"
        }
    ]
})


print(cli_args.argv['integer_a']) # 3
print(cli_args.argv['integer_b']) # 5

python demo.py --integer_a=3 --integer_b=5

License

Licensed under the MIT License. Happy forking :)

Metadata

Release files for cli-args 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for cli-args 1.1.0
File Interpreter ABI Platform
cli_args-1.1.0-py3-none-any.whl Python 3 none any Details

Release files / cli_args-1.1.0-py3-none-any.whl

Download URL cli_args-1.1.0-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf77668caeb2e4309356149f8b709f1d5e66bcac1235e2993797b2472222e748
BLAKE2b-256 checksum
How to use checksums
385153965258d32e931863eb9666cf3195e4cced1630323c1de22a030856bcac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.0

Security for cli-args 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page