cli icon indicating copy to clipboard operation
cli copied to clipboard

Use the custom help template in ShowSubcommand

Open adrian-thurston opened this issue 6 months ago • 4 comments

What type of PR is this?

  • bug

What this PR does / why we need it:

The custom help template was not getting used in subcommand help. This is called when using HideHelpCommand. Updated ShowSubcommand to use the custom template.

It's possible a minor refactor in the help display cases is needed here, but this change fixes our immediate problem.

Which issue(s) this PR fixes:

No known issue, just discovered locally.

Special notes for your reviewer:

None.

Testing

Test case for the bug added.

Release Notes

Bug fix: use the custom help template in a subcommand when in HideHelpCommand is active

adrian-thurston avatar Jun 25 '25 18:06 adrian-thurston

@adrian-thurston the subcommand help is supposed to use the subcommand template. I think you have your logic backwards. If subcommand template is empty then it can use the main command template

dearchap avatar Jul 13 '25 21:07 dearchap

@adrian-thurston the subcommand help is supposed to use the subcommand template. I think you have your logic backwards. If subcommand template is empty then it can use the main command template

@dearchap Should there be a separate customization for the subcommand help then? I'm more interested in customizing it, rather than specializing it differently between command and subcommand.

adrian-thurston avatar Jul 15 '25 16:07 adrian-thurston

@adrian-thurston When you say customization for subcommand what do you mean ?

dearchap avatar Aug 09 '25 21:08 dearchap

@dearchap In V2 we would set CustomHelpTemplate on cli.Command and it would get used for prog cmd --help and prog cmd subcmd --help.

In V3 it gets used only on prog cmd --help. For subcommands it uses the default.

adrian-thurston avatar Aug 18 '25 15:08 adrian-thurston