Skip to content

fix(cli): fix action display in --help when there are few actions #2679

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

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

jouve
Copy link
Contributor

@jouve jouve commented Oct 8, 2023

Changes

display --help actions correctly when there are few actions.

fix #2656

Documentation and testing

Please consider whether this PR needs documentation and tests. This is not required, but highly appreciated:

Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the fix @jouve, nice find.

I took the liberty of refactoring this a bit to be more readable (subjective of course!) and to fix a bug where the help indent was the length of all choices combined instead of the longest choice (which I think is the behavior you wanted. You're still set as the commit author of course. Hope that's alright with you! Thanks again!

@nejch nejch enabled auto-merge (rebase) October 10, 2023 12:12
@nejch nejch merged commit b22d662 into python-gitlab:main Oct 10, 2023
@jouve
Copy link
Contributor Author

jouve commented Oct 10, 2023

no problem, I'd rather you do that than back and forth commits/ comments in the PR :)

the length I used was to try to keep "Action to execute ..." from action: aligned with "show this help message ..." from options: which seemed to be the default HelpFormatter behavior

options:
  -h, --help  show this help message and exit
              ^
action:       ^
  {list}      Action to execute on the GitLab resource.
              ^
              ^ aligned

but I think your idea will look better.

@glensc
Copy link

glensc commented Nov 16, 2023

@nejch the find is mine:

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.

Bogus } in usage
3 participants