Current thinking on required options
Loris Bennett
loris.bennett at fu-berlin.de
Mon Apr 19 05:52:42 EDT 2021
Hi,
I have various small programs which tend to have an interface like the
following example:
usage: grocli [-h] [-o {check,add,delete}] [-u USERS [USERS ...]] [-g GROUP]
Command line grouper tool
optional arguments:
-h, --help show this help message and exit
-o {check,add,delete}, --operation {check,add,delete}
operation to apply
-u USERS [USERS ...], --users USERS [USERS ...]
users to apply operation to
-g GROUP, --group GROUP
group to apply operation to
However, the options -o, -u, and -g are required, not optional.
The documentation
https://docs.python.org/3/library/argparse.html#required
advises against required options and here
https://stackoverflow.com/questions/24180527/argparse-required-arguments-listed-under-optional-arguments
a way of adding a section 'required arguments' to the usage is
described.
I would be interested to know what the general thinking on "required
options" is. Is there just a better way of designing such interfaces?
Cheers,
Loris
--
This signature is currently under construction.
More information about the Python-list
mailing list