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.610.1611/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.610.1611.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32ce5b2e3e1275cca29ab236e197484b3333652753ca23d437d01daeefadb9b5 |
|
MD5 | 6e5bae0e008a1c8a8a41dc5cfd3b5b0e |
|
BLAKE2b-256 | 1e5329920695457a22050c3f28fe33b3e83db6457f4b5b04c3d467a1fe169177 |
Hashes for pgetopt_jyrgenn-2020.610.1611-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f51c8fd7d07c8ecf513299d296a8f392a12b6e9436c93d393ef21f123cf6df6b |
|
MD5 | 654a72a44e06d1914842b813e42b80f1 |
|
BLAKE2b-256 | 72b3db05ad2ad866e9dc93db16b8993914d1f74e0e7c1471ff7cbdff9fb1196e |