Providing a straightforward way to create command-line arguments.
Project description
jarguments
simplifying args jargon
Summary
Providing a straightforward way to create command-line arguments.
Works on Python 3.6 and above. Tested on Windows 10.
Contents
Installation
pip install jarguments
Usage
Library
There are three steps to using the jarguments library:
-
Import the jarguments library.
import jarguments as j
-
Provide your arguments with jarguments' classes.
args = j.JParser( j.JBool('show-text', help='determines whether "text" is shown'), j.JInt('number', default=1), j.JArgument('text', type=str, multiple=True), )
-
Use the outputs; they're parsed automatically!
if args.show_text: for _ in range(args.number): print(args.text)
Command-line
-
Now you can run your script with arguments:
$ python example.py --show-text --text "hello" "world" ["hello", "world"]
-
Arguments without a default value are required. If you don't provide them, the script will raise an error:
$ python example.py --show-text error: the following arguments are required: --text
-
If you want to see help messages, run your script with the
-h
or--help
flag:$ python example.py -h usage: example.py [-h] [--show-text [SHOW_TEXT]] [--number NUMBER] --text [TEXT ...] options: -h, --help show this help message and exit --show-text [SHOW_TEXT] determines whether "text" is shown --number NUMBER --text [TEXT ...]
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 Distribution
jarguments-0.1.0.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for jarguments-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ae8f4f6685d8155108cf27eebc4d0e1b8323e2c1380799f920967c121c1ab31 |
|
MD5 | 849a66cb5899f47f473c7a7ef2b7d8ba |
|
BLAKE2b-256 | ce74989a8eaba2634a345f540c3cb1cb7e1e65e6116b047992e80f9dd133be5e |