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/ni/jpylib/
The full documentation for this version is at https://git.w21.org/ni/jpylib/-/blob/v2020.710.1817/README-pgetopt.md
[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.710.1817.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4187ecf98e3df2e67ed589bf6c40782638afd4c61c65fca13d85fa2da5c79dc8 |
|
MD5 | cb96f69c12698f274f79629ad696cea2 |
|
BLAKE2b-256 | c39628193649d875c64623f526ea8639e165276575e5d19e4ce380a62f33eb86 |
Hashes for pgetopt_jyrgenn-2020.710.1817-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98314f0c76cf54b48ad8c4f330b885a188dea67e0488acf56a42e7392a1dba86 |
|
MD5 | d0314878e60d6b22e7e20e5038504805 |
|
BLAKE2b-256 | 85ab6fe508cbafdd9b0d535669f0a2987162dca71d803947b98235a7b2b98d0e |