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
are installed by default and print a
help message.
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.808.1528/README-pgetopt.md
[ni@w21.org 2020-08-08]
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.808.1528.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f966cdba25916de59615a091b0af1821b5c93e544232088599a3796e4b5b09f |
|
MD5 | 0f2ca397d17682d73b3474c267d792af |
|
BLAKE2b-256 | 2cda6172f7fa2603a89d6d1d76ed7dcc396f52140073660ad541c9ebf535e0b3 |
Hashes for pgetopt_jyrgenn-2020.808.1528-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa9fdfad3f3d853c8643ca1cfbe7014d509be0953d3d37bfc62bdd5ffb4309ff |
|
MD5 | 9f2d9ac63a8992e6d8fb2b315adce679 |
|
BLAKE2b-256 | 188139b7dd40ae86f592be0e0f81ef3de95064d84c2d5a3510c6a35b63bbbedd |