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.1607.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d5816a7fd17e99b34e55e4ee1eba77e81ae6249360f532d9607282180bcc1e1 |
|
MD5 | bdf98d4eda90f6a0eb0793383e9a314b |
|
BLAKE2b-256 | 6069a9279f7e9b814a082d38ec02a029c03278d7a54fa6d45fb52c9373122645 |
Hashes for pgetopt_jyrgenn-2020.524.1607-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5fb925097d5fa6468803d0b5aeb059103cab9492885a81b2ba2edd8841f1039 |
|
MD5 | be48d6996d473928e2a097167ba9adec |
|
BLAKE2b-256 | cbcd497d950efad6c8e5063344372706085002d371d1c70effc4a817f3547404 |