Skip to content

Commit e2ef712

Browse files
committed
use Command.Hidden
1 parent cea3475 commit e2ef712

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

cmd/gen-docs/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ func main() {
1919
dir := docCmd.StringP("doc-path", "", "", "Path directory where you want generate doc files")
2020
help := docCmd.BoolP("help", "h", false, "Help about any command")
2121

22-
for _, cmd := range command.RootCmd.Commands() {
23-
if _, hidden := cmd.Annotations["hidden"]; hidden {
24-
command.RootCmd.RemoveCommand(cmd)
25-
}
26-
}
27-
2822
if err := docCmd.Parse(os.Args); err != nil {
2923
os.Exit(1)
3024
}

command/credits.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ var creditsCmd = &cobra.Command{
4949
gh credits -s # display a non-animated thank you
5050
gh credits | cat # just print the contributors, one per line
5151
`,
52-
Args: cobra.ExactArgs(0),
53-
RunE: ghCredits,
54-
Annotations: map[string]string{"hidden": "true"},
52+
Args: cobra.ExactArgs(0),
53+
RunE: ghCredits,
54+
Hidden: true,
5555
}
5656

5757
func ghCredits(cmd *cobra.Command, _ []string) error {

command/repo.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ $ gh repo credits cool/repo # view credits for cool/repo
100100
$ gh repo credits -s # print a non-animated thank you
101101
$ gh repo credits | cat # pipe to just print the contributors, one per line
102102
`,
103-
Args: cobra.MaximumNArgs(1),
104-
RunE: repoCredits,
105-
// NB will actually be hidden once https://github.com/cli/cli/pull/1106 is in
106-
Annotations: map[string]string{"hidden": "true"},
103+
Args: cobra.MaximumNArgs(1),
104+
RunE: repoCredits,
105+
Hidden: true,
107106
}
108107

109108
func parseCloneArgs(extraArgs []string) (args []string, target string) {

command/root.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,9 @@ func rootHelpFunc(command *cobra.Command, args []string) {
363363
continue
364364
}
365365
s := " " + rpad(c.Name()+":", c.NamePadding()) + c.Short
366-
_, hidden := c.Annotations["hidden"]
367366
if includes(coreCommandNames, c.Name()) {
368367
coreCommands = append(coreCommands, s)
369-
} else if !hidden {
368+
} else if !c.Hidden {
370369
additionalCommands = append(additionalCommands, s)
371370
}
372371
}

0 commit comments

Comments
 (0)