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

Fix: Nested help command has a incorrect HelpName #1581

Merged
merged 3 commits into from
Nov 11, 2022

Conversation

remiposo
Copy link
Contributor

@remiposo remiposo commented Nov 9, 2022

What type of PR is this?

(REQUIRED)

  • bug

What this PR does / why we need it:

(REQUIRED)

  • Fixed incorrect HelpName of helpCommand
  • Changed HideHelp of helpCommand to avoid nested helpCommand
  • Added related tests
    • Fixed ShowCommandHelp to pass tests

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #1570

Special notes for your reviewer:

(fill-in or delete this section)

In ShowCommandHelp, len(c.Subcommands) != 0 is used as the condition.. What does it mean?
Even if a command has no subcommand, I think helpCommand should be added.
In fact, helpCommand can be invoked although it does not appear in help msg.

I didn't change it this time, because some of the existing test cases asserting entire help msg failed.

Testing

(fill-in or delete this section)

  • Test_helpCommand_HelpName tests HelpName of helpCommand
  • Test_helpCommand_HideHelpCommand and Test_helpCommand_HideHelpFlag test nested helpCommand call

Release Notes

(REQUIRED)


@remiposo remiposo requested a review from a team as a code owner November 9, 2022 17:46
dearchap
dearchap previously approved these changes Nov 10, 2022
@dearchap
Copy link
Contributor

Thanks for the complete patch @remiposo

if !c.HideHelp {
if !c.HideHelpCommand && len(c.Subcommands) != 0 && c.Command(helpName) == nil {
c.Subcommands = append(c.Subcommands, helpCommandDontUse)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@remiposo can you add a test case for app -h help and app cmd -h help etc ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@remiposo
Copy link
Contributor Author

@dearchap Thank you for your review.

  • Add test cases that you pointed out
  • Add test on appending help in ShowCommandHelp to increase coverage

@dearchap dearchap changed the base branch from main to v2-maint November 11, 2022 12:33
@dearchap dearchap changed the base branch from v2-maint to main November 11, 2022 12:34
@dearchap dearchap merged commit d219eb1 into urfave:main Nov 11, 2022
@remiposo remiposo deleted the remiposo/issue_1570 branch November 11, 2022 13:37
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.

Nested help command has a incorrect HelpName
2 participants