This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients paul.j3, rhettinger, ygingras
Date 2020-10-10.07:32:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1602315131.88.0.77473699492.issue41980@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-10-10 07:32:11paul.j3setrecipients: + paul.j3, rhettinger, ygingras
2020-10-10 07:32:11paul.j3setmessageid: <1602315131.88.0.77473699492.issue41980@roundup.psfhosted.org>
2020-10-10 07:32:11paul.j3linkissue41980 messages
2020-10-10 07:32:11paul.j3create