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.524.1452.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7aff1bd209b2f97c0b587807300f377e770442b8fd979cffeebca68e94a5984 |
|
MD5 | ae6aad3a1880094b6567032c36a774fb |
|
BLAKE2b-256 | 1ef4d7c46730acce7a6f3eb6730cbabaffd3f6142a027d033749a248b619cabb |
Hashes for pgetopt_jyrgenn-2020.524.1452-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f509d2a7592cdee7d7f8b308929ac5df67398ed7914966d2581ac11dde5402a7 |
|
MD5 | 4cca303484c9b0a1315eb187baa763d6 |
|
BLAKE2b-256 | 68331e5b7ca2d7d47bdf7e2402168429caa5ca9982e18a2f6c1f28c6084c40bf |