Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: improve help info format for subcommands #2103

Merged
merged 1 commit into from
Jul 15, 2023

Conversation

leemars
Copy link
Contributor

@leemars leemars commented Jul 14, 2023

Pull Request Checklist

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

Describe what you have changed in this PR.

Improve help info format for subcommands.

  • Set metavar to empty for subparsers
  • Remove extra line breaks and indent block when action_help is empty
  • Remove extra continuous spaces in usage info

By the way, it also fixed the help info difference for older Python version.

@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2023

Codecov Report

Patch coverage: 88.23% and project coverage change: +0.01 🎉

Comparison is base (df0b2e9) 84.48% compared to head (d596348) 84.50%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2103      +/-   ##
==========================================
+ Coverage   84.48%   84.50%   +0.01%     
==========================================
  Files         100      100              
  Lines        9675     9686      +11     
  Branches     2124     2128       +4     
==========================================
+ Hits         8174     8185      +11     
  Misses       1040     1040              
  Partials      461      461              
Flag Coverage Δ
unittests 84.27% <88.23%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/pdm/cli/utils.py 84.76% <84.61%> (+0.52%) ⬆️
src/pdm/cli/commands/cache.py 83.33% <100.00%> (ø)
src/pdm/cli/commands/self_cmd.py 70.32% <100.00%> (ø)
src/pdm/cli/commands/venv/__init__.py 84.84% <100.00%> (ø)
src/pdm/core.py 91.55% <100.00%> (-0.06%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

verbose_option.add_to_parser(self.parser)
ignore_python_option.add_to_parser(self.parser)
pep582_option.add_to_parser(self.parser)

self.subparsers = self.parser.add_subparsers(parser_class=ArgumentParser, dest="fooo")
self.subparsers = self.parser.add_subparsers(parser_class=ArgumentParser, title="commands", metavar="")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commands is the default title?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

In previous revision, the 81L self.parser._positionals.title was set to Commands, force argparse displays "Commands:" as title instead of "Positional Arguments:". But it can be done by setting subparsers title to "commands", as same as other venv/self/cache subparsers, without touching the internal members.

@frostming frostming merged commit aaa6575 into pdm-project:main Jul 15, 2023
@j178 j178 mentioned this pull request Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants