POSIX-conformant command-line option parser (plus long options)
Project description
POSIX-conformant command-line option parser (plus long options)
Use it like this:
import pgetopt
ovc, args = pgetopt.parse({
# opt: (name, type, default value, helptext[, arg name])
"s": ("schmooze", bool, 0, "increase schmooziness"),
"o": ("output_file", str, None, "output file (or stdout)", "NAME"),
"n": ("repetitions", int, 3, "number of repetitions"),
"d": ("debug", str, [], "debug topics", "DEBUG_TOPIC"),
# keyword: value
"_arguments": ["string_to_print", "..."],
"_help_header": "print a string a number of times",
"_help_footer": "This is just an example program.",
})
On return, the option value container ovc
has the following fields:
ovc.schmooze
: the number of -s
options counted,
ovc.output_file
: the parameter of -o
or --output-file
, or None
ovc.repetitions
: the parameter of -n
or --repetitions
, or 3
ovc.debug
: a list with all parameters given to -d
or --debug
Options -h
, --help
, -?
, --usage
are installed by default and
print a help message or a brief usage message, respectively.
args
holds the remaining arguments behind the last option.
Call help(pgetopt)
for details.
More information at https://git.w21.org/ni/jpylib/
The full documentation for this version is at https://git.w21.org/ni/jpylib/-/blob/v2020.710.1339/README-pgetopt.md
[ni@w21.org 2020-05-22]
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
Built Distribution
Hashes for pgetopt-jyrgenn-2020.710.1339.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a888ffac4d00b923751f73dbfddbaa7e737b34dde04e80584cda2acdeaf6b59a |
|
MD5 | 5b6481511320258332b4dc5057faafe1 |
|
BLAKE2b-256 | aef16a3e49c907f8892b3e2fbfe237d4473c08a42067ae57f364d878126d476c |
Hashes for pgetopt_jyrgenn-2020.710.1339-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a97868f1318742823645a0062f912b27916b3cf4f609e398ff585982c7174d9 |
|
MD5 | e7fad06e2c58b75dad631b04e2dbf77a |
|
BLAKE2b-256 | eabb9d92a7127cfbb0c883af64d20e2d09dfc43561fadfcaf4782470486d250c |