POSIX-conformant command-line option parser (plus long options)
Project description
POSIX-conformant command-line option parser (plus long options)
[This project is now integrated into jpylib
and will no longer be
released separately. Actually, the jpylib.pgetopts
is already more
up to date than this.]
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/v2022.812.1632/doc/pgetopt.md
[ni@w21.org 2022-08-12]
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-2022.812.1632.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d942de3f98df02b229cf18b170fa8d6596f461e7b845933d8c00f200accc7afc |
|
MD5 | ab6a2a1e8c11c6f361949d418cebacee |
|
BLAKE2b-256 | 87d53e2b01de53dbf013fc5f518e4035757ce5e6444a136e1f60ca0c1c3acb7c |
Hashes for pgetopt_jyrgenn-2022.812.1632-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7b999d5b56758e5a23a0f8efd85001f4f4f862d3571db895fd7335a79d8a6a1 |
|
MD5 | 41e7a36f13c2dc192fa06d341acbb953 |
|
BLAKE2b-256 | 56795500dcb7f32abc7d3ba51ee1391e8966c267bd29b7ab6f63c717aec404e3 |