paul j3 <ajipa...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to