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.809.1501/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-2020.809.1501.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9005bdcd6d71c713a45b0d36d52ec8db2865f7f29be83cd4b1801a6128566b9 |
|
MD5 | 898d8a403e7ad17dca81240730b246b1 |
|
BLAKE2b-256 | bf9338c4b46ed83122d6c83b6b7472491623ec6f3048e1e13ffad8f8b0daac40 |
Hashes for pgetopt_jyrgenn-2020.809.1501-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea335adb7a02e0f518cd11f2e118a9793f9a0857e5a3086b8c92a7087b49436c |
|
MD5 | f360faf681a4512741e7e11a91fcfd6e |
|
BLAKE2b-256 | 5aa158a06b771fd7e25c0cb23d4a796a872a9824c6191ae552aa7bd7b28093b0 |