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.1244/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.1244.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 456421067da77a1bdeffa75788823911e294f036133b90b12c056b800d868f40 |
|
MD5 | 992fc68eed0aa6b781e198c1ad9cda38 |
|
BLAKE2b-256 | 08f53f4e0d30f082ba426005e228fbf27977dd8e5885f019b46fbaa2f71f7d77 |
Hashes for pgetopt_jyrgenn-2020.809.1244-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 722040acd6e9f91dbd48f3ffefd5ee0f13cca5a4d01e4c33de418d9cf835bf58 |
|
MD5 | 3b77829fa4c15c490cfe5dd43a0b0079 |
|
BLAKE2b-256 | 68cbfcfb7df8c87bbcaa3e8231495641bac0cafb709cf1329bb3c8c3b7a063b8 |