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/v2022.812.1623/doc/pgetopt.md
[ni@w21.org 2020-08-09]
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-2022.812.1623.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 508423b421521a26154bd5f3d629e0451db83937b530649bb399b262940e7087 |
|
MD5 | 1573bcb339836f9b8c6787efc1ef3606 |
|
BLAKE2b-256 | 9453f234e2676d26488e08f60a88050f70e7a323c4fd592ae200a451e30ad6a8 |
Hashes for pgetopt_jyrgenn-2022.812.1623-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 308d4eb7fa2f1ff9bf1921945ca3984e242994a5031c1b2a1a9c776c26a05e9d |
|
MD5 | 884509c4cfa9a4046da46b332094f643 |
|
BLAKE2b-256 | d635320199b91db3b5d607b23300ea3abf9887a7e0d7fd6ea9ea0d5e8ff3dade |