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/python_modules/pgetopt
[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.606.1606.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05c9ee1273cd4407b35e79fe0cb2c9a6dd56f62b57779986d16f828784d5a7e5 |
|
MD5 | 6a126e6d4e865e245dfd317ef9e061d3 |
|
BLAKE2b-256 | f6960c2675a34db838ff589be126bbbd289f4844c8bd04976e00565c59e00e74 |
Hashes for pgetopt_jyrgenn-2020.606.1606-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3d638cf6e2b23875f13ffe2ce0e7aefc39a5ffb6d9ba039438f4a16d90f32e3 |
|
MD5 | 633c5dbdd36cff04d9e8bc53eb1cf480 |
|
BLAKE2b-256 | fe33b0dc0f6806f1a5e67cff4b4bcc1247ec8cf4b7d44b63c7237a8efca78174 |