Command line arguments. Made simple.
Project description
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 :)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file cli_args-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: cli_args-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf77668caeb2e4309356149f8b709f1d5e66bcac1235e2993797b2472222e748 |
|
MD5 | 00082b25814ede6a5b75b05bf0ac014d |
|
BLAKE2b-256 | 385153965258d32e931863eb9666cf3195e4cced1630323c1de22a030856bcac |