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.528.38.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 841685482cc75ae4bbc631135ba6bc1e8dcef9ea03fb7239ab98b3ca9b449f16 |
|
MD5 | 0a647a43e8d4bd55b3d7d0522528241a |
|
BLAKE2b-256 | 9e01e52ea2bac3ea50283cc0e91ad6525282a534fcb0d92b3bd997472acddd75 |
Hashes for pgetopt_jyrgenn-2020.528.38-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbd4003de5796c7c562444c834390082db76f04de8eda42d29b210c7af808cab |
|
MD5 | e4472ab0779653d3e3b145c66aabadbb |
|
BLAKE2b-256 | 198fb5b9304297d2065fffe45410ac1d3a4a5d5cdf3e6a3c3c359d77ff1b4963 |