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

add FailSubcommand, WriteUsageForSubcommand, WriteHelpForSubcommand #156

merged 3 commits into from Sep 18, 2021


Copy link

Closes #134 #135 #139

This pr makes it possible to print usage and help text for explicit subcommands. It adds three new functions:


These behave like their non-subcommand cousins, except that they also take a subcommand name (or a sequence of subcommand names in the case of nested subcommands)

Copy link

codecov-commenter commented May 9, 2021

Codecov Report

Merging #156 (f2f8764) into master (66cb696) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #156   +/-   ##
  Coverage   100.00%   100.00%           
  Files            5         5           
  Lines          650       679   +29     
+ Hits           650       679   +29     
Impacted Files Coverage Δ
parse.go 100.00% <100.00%> (ø)
usage.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66cb696...f2f8764. Read the comment docs.

Copy link

Thanks for this. Is there a way to enable printing help messages by default for nested subcommands? As I understand it, even with this pull request merged I would still have to call Parser.WriteHelpForSubcommand in each problematic subcommands code.

Copy link

Keithcat1 commented Jul 10, 2021

Why isn't this merged yet? It doesn't seem to be blocking on anything.

Copy link

@alexflint could we merge this?

@alexflint alexflint merged commit a4afd6a into master Sep 18, 2021
6 checks passed
@alexflint alexflint deleted the usage-for-subcommands branch September 18, 2021 15:57
Copy link

xvello commented Oct 1, 2021

Hello @alexflint, thanks a lot for your work on this!

It does look like #139 is not completely fixed yet though: we are still printing p.description, which is obtained by calling Description() on the root command, not the subcommand selected by the user.

I am experimenting on this branch, but I'd love your input. Do you have any opinion on how that should be implemented?

Copy link
Owner Author

@xvello you are exactly right. I've reopened #139.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Find a way to print help message for nested subcommands
5 participants