cli icon indicating copy to clipboard operation
cli copied to clipboard

Support Help Template overrides for Subcommands

Open ddouglas opened this issue 2 years ago • 2 comments

What type of PR is this?

  • bug

What this PR does / why we need it:

When using the Subcommands, it is currently no possible to override the Subcommand Template that is used due to the Command being overwritten when initializing Context inside of the RunAsSubcommand function. I outline everything in #1303. The comment in the code details how I came to the conclusion I came to. Ideally, the Command would not be overridden but set to the Parent Command that houses the Subcommands that are being executed.

Which issue(s) this PR fixes:

Fixes #1303

Special notes for your reviewer:

This is a bandaid at best. I do not expect this PR to be merged. I might update it later with an actual fix, but I just wanted to test my hypothesis, I did that, this works, but ideally, you give Subcommand Context to the NewContext Command should the c.Command is initialized with the parent command instead of a empty *cli.Command

Release Notes

Adds Support for overriding cli.SubcommandHelpTemplate

ddouglas avatar Nov 06 '21 19:11 ddouglas

@ddouglas Sorry for the big delay 😭 What do you think about adding a new field to App such as CustomSubcommandHelpTemplate instead of what you have here? This would mean bumping from a "bug" to a "feature" given the increased API surface area, but I think it'd result in fewer surprises in the future.

meatballhat avatar Apr 26 '22 03:04 meatballhat

@ddouglas Can you add a test case as well ?

dearchap avatar Apr 26 '22 11:04 dearchap

@ddouglas I'm going to close this and push another PR with the proper fix/tests.

dearchap avatar Sep 23 '22 20:09 dearchap