Closed
Description
Feature or enhancement
GNU getopt
supports options with optional arguments. For example GNU grep
can be used with option --color=auto
and with just --color
. Unix getopt
does not need it, because it stops after encountering first nonoption argument, but GNU getopt
needs it to support options intermixed with positional arguments. getopt.gnu_getopt()
needs it for the same reason.
Neither optparse
nor argparse
directly support such kind of optional arguments. It can be supported in optparse
with custom callback, but support of optional arguments in argparse
is non-standard. In future I'm planning to add support of such kind of optional arguments in argparse
, and maybe in optparse
.