Skip to content
This repository was archived by the owner on Oct 17, 2021. It is now read-only.

Commit 610063a

Browse files
committed
Add hidden commands
1 parent 1c3ee92 commit 610063a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

command.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ type CommandSpec struct {
1919
// Desc is the description of the command.
2020
// The first line is used as an abbreviated description.
2121
Desc string
22+
23+
// Hidden indicates that this command should not show up in it's parent's
24+
// subcommand help.
25+
Hidden bool
2226
}
2327

2428
// ShortDesc returns the first line of Desc.

help.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ func renderHelp(cmd Command, fl *flag.FlagSet, w io.Writer) {
5050
fmt.Fprint(w, "Commands:\n")
5151
}
5252
for _, cmd := range pc.Subcommands() {
53+
if cmd.Spec().Hidden {
54+
continue
55+
}
56+
5357
fmt.Fprintf(w, "\t%v\t%v\n", cmd.Spec().Name, cmd.Spec().ShortDesc())
5458
}
5559
}

0 commit comments

Comments
 (0)