Message378369
For ArgumentParser, prog is defined as:
prog - The name of the program (default: sys.argv[0])
The comment in the `add_subparsers` method is:
# prog defaults to the usage message of this parser, skipping
# optional arguments and with no "usage:" prefix
if kwargs.get('prog') is None:
formatter = self._get_formatter()
positionals = self._get_positional_actions()
groups = self._mutually_exclusive_groups
formatter.add_usage(self.usage, positionals, groups, '')
kwargs['prog'] = formatter.format_help().strip()
and this keyword is saved as the action `self._prog_prefix.
Later in `add_parser` this is amended with:
kwargs['prog'] = '%s %s' % (self._prog_prefix, name)
The intent is to provide the string required to run a particular subparser (sub-command), the `prog` of the main, positionals, and the subcommand. (It doesn't handle all 'required' arguments correctly.)
The programmer has three places where they can customize this 'prog'.
So the default 'prog' as the 'add_subarsers' level is indeed just the main 'prog' plus 'positionals'. The default 'prog' display with the subcommand usage add the subcommand's name.
It's a complicated sequence, but I think the description for the 'add_subparsers' 'prog' is enough. |
|
Date |
User |
Action |
Args |
2020-10-10 07:32:11 | paul.j3 | set | recipients:
+ paul.j3, rhettinger, ygingras |
2020-10-10 07:32:11 | paul.j3 | set | messageid: <1602315131.88.0.77473699492.issue41980@roundup.psfhosted.org> |
2020-10-10 07:32:11 | paul.j3 | link | issue41980 messages |
2020-10-10 07:32:11 | paul.j3 | create | |
|