if help is None:
help = ''
- if '%(default)' not in help:
- if action.default is not SUPPRESS:
- defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
- if action.option_strings or action.nargs in defaulting_nargs:
- t = self._theme
- default_str = _(" (default: %(default)s)")
- prefix, suffix = default_str.split("%(default)s")
- help += (
- f" {t.default}{prefix.lstrip()}"
- f"{t.default_value}%(default)s"
- f"{t.default}{suffix}{t.reset}"
- )
+ if (
+ '%(default)' not in help
+ and action.default is not SUPPRESS
+ and not action.required
+ ):
+ defaulting_nargs = (OPTIONAL, ZERO_OR_MORE)
+ if action.option_strings or action.nargs in defaulting_nargs:
+ t = self._theme
+ default_str = _(" (default: %(default)s)")
+ prefix, suffix = default_str.split("%(default)s")
+ help += (
+ f" {t.default}{prefix.lstrip()}"
+ f"{t.default_value}%(default)s"
+ f"{t.default}{suffix}{t.reset}"
+ )
return help
argument_signatures = [
Sig('--foo', help='foo help - oh and by the way, %(default)s'),
Sig('--bar', action='store_true', help='bar help'),
+ Sig('--required', required=True, help='some help'),
Sig('--taz', action=argparse.BooleanOptionalAction,
help='Whether to taz it', default=True),
Sig('--corge', action=argparse.BooleanOptionalAction,
[Sig('--baz', type=int, default=42, help='baz help')]),
]
usage = '''\
- usage: PROG [-h] [--foo FOO] [--bar] [--taz | --no-taz] [--corge | --no-corge]
- [--quux QUUX] [--baz BAZ]
+ usage: PROG [-h] [--foo FOO] [--bar] --required REQUIRED [--taz | --no-taz]
+ [--corge | --no-corge] [--quux QUUX] [--baz BAZ]
spam [badger]
'''
help = usage + '''\
-h, --help show this help message and exit
--foo FOO foo help - oh and by the way, None
--bar bar help (default: False)
+ --required REQUIRED some help
--taz, --no-taz Whether to taz it (default: True)
--corge, --no-corge Whether to corge it
--quux QUUX Set the quux (default: 42)