Skip to content

Commit

Permalink
command: allow explicitly requesting help for unlisted commands
Browse files Browse the repository at this point in the history
When the help --all metaflag is set, allow help to select an unlisted command
by name even if it would otherwise be filtered out.
  • Loading branch information
creachadair committed Mar 11, 2024
1 parent 64b71fd commit d248327
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,13 @@ func walkArgs(env *Env, args []string) *Env {

for _, arg := range args {
// If no corresponding subcommand is found, or if the subtree starting
// with that command is unlisted, report no match.
// with that command is unlisted and we weren't asked to show unlisted
// things, report no match.
next := cur.Command.FindSubcommand(arg)
if next == nil || next.Unlisted {
if next == nil {
return nil
} else if next.Unlisted && !env.hflag.wantUnlisted() {
return nil // skip unlisted commands when not flagged on
}
// Populate flags so that the help text will include them.
next.setFlags(cur, &next.Flags)
Expand Down

0 comments on commit d248327

Please sign in to comment.