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
The full documentation for this version is at https://git.w21.org/python_modules/pgetopt/-/blob/v2020.705.1545/README.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.705.1545.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1676a2a42630227c569aad1b59f18af0147937e3107f112e07cfb8e6fe6685c2 |
|
MD5 | 31832859b10eb8e65fea9161b018f510 |
|
BLAKE2b-256 | 402651c16fb14de89c4fda66a10656e7274188f2c41b251a556f5720c92ab3df |
Hashes for pgetopt_jyrgenn-2020.705.1545-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 290bf24e39be357d6173342dc5dcb102680b1fcb98a53ceb6083be42434ac4c7 |
|
MD5 | 677a3dd213ca3e66b1536e386b433543 |
|
BLAKE2b-256 | 732416f2e138c90122e822991461bf0015ec425a1243ac99efa79e48b1520823 |