diff --git a/cli/command/checkpoint/cmd.go b/cli/command/checkpoint/cmd.go index 30e9ce364c..097d4dbf90 100644 --- a/cli/command/checkpoint/cmd.go +++ b/cli/command/checkpoint/cmd.go @@ -9,11 +9,11 @@ import ( // NewCheckpointCommand returns the `checkpoint` subcommand (only in experimental) func NewCheckpointCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ - Use: "checkpoint", - Short: "Manage checkpoints", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Tags: map[string]string{"experimental": "", "version": "1.25"}, + Use: "checkpoint", + Short: "Manage checkpoints", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"experimental": "", "version": "1.25"}, } cmd.AddCommand( newCreateCommand(dockerCli), diff --git a/cli/command/config/cmd.go b/cli/command/config/cmd.go index 1f762596c2..0adadadfac 100644 --- a/cli/command/config/cmd.go +++ b/cli/command/config/cmd.go @@ -11,11 +11,11 @@ import ( // nolint: interfacer func NewConfigCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ - Use: "config", - Short: "Manage Docker configs", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Tags: map[string]string{"version": "1.30"}, + Use: "config", + Short: "Manage Docker configs", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"version": "1.30"}, } cmd.AddCommand( newConfigListCommand(dockerCli), diff --git a/cli/command/container/opts_test.go b/cli/command/container/opts_test.go index 0aa043839c..9403898660 100644 --- a/cli/command/container/opts_test.go +++ b/cli/command/container/opts_test.go @@ -45,10 +45,7 @@ func TestValidateAttach(t *testing.T) { // nolint: unparam func parseRun(args []string) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) { - flags := pflag.NewFlagSet("run", pflag.ContinueOnError) - flags.SetOutput(ioutil.Discard) - flags.Usage = nil - copts := addFlags(flags) + flags, copts := setupRunFlags() if err := flags.Parse(args); err != nil { return nil, nil, nil, err } @@ -60,6 +57,14 @@ func parseRun(args []string) (*container.Config, *container.HostConfig, *network return containerConfig.Config, containerConfig.HostConfig, containerConfig.NetworkingConfig, err } +func setupRunFlags() (*pflag.FlagSet, *containerOptions) { + flags := pflag.NewFlagSet("run", pflag.ContinueOnError) + flags.SetOutput(ioutil.Discard) + flags.Usage = nil + copts := addFlags(flags) + return flags, copts +} + func parseMustError(t *testing.T, args string) { _, _, _, err := parseRun(strings.Split(args+" ubuntu bash", " ")) assert.Error(t, err, args) @@ -227,20 +232,21 @@ func TestParseWithMacAddress(t *testing.T) { } } -func TestParseWithMemory(t *testing.T) { - invalidMemory := "--memory=invalid" - _, _, _, err := parseRun([]string{invalidMemory, "img", "cmd"}) - testutil.ErrorContains(t, err, invalidMemory) +func TestRunFlagsParseWithMemory(t *testing.T) { + flags, _ := setupRunFlags() + args := []string{"--memory=invalid", "img", "cmd"} + err := flags.Parse(args) + testutil.ErrorContains(t, err, `invalid argument "invalid" for "-m, --memory" flag`) _, hostconfig := mustParse(t, "--memory=1G") assert.Equal(t, int64(1073741824), hostconfig.Memory) } func TestParseWithMemorySwap(t *testing.T) { - invalidMemory := "--memory-swap=invalid" - - _, _, _, err := parseRun([]string{invalidMemory, "img", "cmd"}) - testutil.ErrorContains(t, err, invalidMemory) + flags, _ := setupRunFlags() + args := []string{"--memory-swap=invalid", "img", "cmd"} + err := flags.Parse(args) + testutil.ErrorContains(t, err, `invalid argument "invalid" for "--memory-swap" flag`) _, hostconfig := mustParse(t, "--memory-swap=1G") assert.Equal(t, int64(1073741824), hostconfig.MemorySwap) @@ -365,7 +371,10 @@ func TestParseDevice(t *testing.T) { func TestParseModes(t *testing.T) { // pid ko - _, _, _, err := parseRun([]string{"--pid=container:", "img", "cmd"}) + flags, copts := setupRunFlags() + args := []string{"--pid=container:", "img", "cmd"} + require.NoError(t, flags.Parse(args)) + _, err := parse(flags, copts) testutil.ErrorContains(t, err, "--pid: invalid PID mode") // pid ok @@ -385,14 +394,18 @@ func TestParseModes(t *testing.T) { if !hostconfig.UTSMode.Valid() { t.Fatalf("Expected a valid UTSMode, got %v", hostconfig.UTSMode) } +} +func TestRunFlagsParseShmSize(t *testing.T) { // shm-size ko - expectedErr := `invalid argument "a128m" for --shm-size=a128m: invalid size: 'a128m'` - _, _, _, err = parseRun([]string{"--shm-size=a128m", "img", "cmd"}) + flags, _ := setupRunFlags() + args := []string{"--shm-size=a128m", "img", "cmd"} + expectedErr := `invalid argument "a128m" for "--shm-size" flag: invalid size: 'a128m'` + err := flags.Parse(args) testutil.ErrorContains(t, err, expectedErr) // shm-size ok - _, hostconfig, _, err = parseRun([]string{"--shm-size=128m", "img", "cmd"}) + _, hostconfig, _, err := parseRun([]string{"--shm-size=128m", "img", "cmd"}) require.NoError(t, err) if hostconfig.ShmSize != 134217728 { t.Fatalf("Expected a valid ShmSize, got %d", hostconfig.ShmSize) diff --git a/cli/command/container/prune.go b/cli/command/container/prune.go index f466c44ad0..e144d8d7ea 100644 --- a/cli/command/container/prune.go +++ b/cli/command/container/prune.go @@ -35,7 +35,7 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command { fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed))) return nil }, - Tags: map[string]string{"version": "1.25"}, + Annotations: map[string]string{"version": "1.25"}, } flags := cmd.Flags() diff --git a/cli/command/image/prune.go b/cli/command/image/prune.go index c49edac277..41590e4ecb 100644 --- a/cli/command/image/prune.go +++ b/cli/command/image/prune.go @@ -37,7 +37,7 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command { fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed))) return nil }, - Tags: map[string]string{"version": "1.25"}, + Annotations: map[string]string{"version": "1.25"}, } flags := cmd.Flags() diff --git a/cli/command/network/prune.go b/cli/command/network/prune.go index 1b00a5c028..879e2bd554 100644 --- a/cli/command/network/prune.go +++ b/cli/command/network/prune.go @@ -33,7 +33,7 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command { } return nil }, - Tags: map[string]string{"version": "1.25"}, + Annotations: map[string]string{"version": "1.25"}, } flags := cmd.Flags() diff --git a/cli/command/node/cmd.go b/cli/command/node/cmd.go index b3090d5d71..4ae0f4f094 100644 --- a/cli/command/node/cmd.go +++ b/cli/command/node/cmd.go @@ -14,11 +14,11 @@ import ( // NewNodeCommand returns a cobra command for `node` subcommands func NewNodeCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ - Use: "node", - Short: "Manage Swarm nodes", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Tags: map[string]string{"version": "1.24"}, + Use: "node", + Short: "Manage Swarm nodes", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"version": "1.24"}, } cmd.AddCommand( newDemoteCommand(dockerCli), diff --git a/cli/command/plugin/cmd.go b/cli/command/plugin/cmd.go index c298934937..c30f97fd1d 100644 --- a/cli/command/plugin/cmd.go +++ b/cli/command/plugin/cmd.go @@ -10,11 +10,11 @@ import ( // nolint: interfacer func NewPluginCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ - Use: "plugin", - Short: "Manage plugins", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Tags: map[string]string{"version": "1.25"}, + Use: "plugin", + Short: "Manage plugins", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"version": "1.25"}, } cmd.AddCommand( diff --git a/cli/command/plugin/upgrade.go b/cli/command/plugin/upgrade.go index 0e3f56ff62..f71306c70e 100644 --- a/cli/command/plugin/upgrade.go +++ b/cli/command/plugin/upgrade.go @@ -26,7 +26,7 @@ func newUpgradeCommand(dockerCli *command.DockerCli) *cobra.Command { } return runUpgrade(dockerCli, options) }, - Tags: map[string]string{"version": "1.26"}, + Annotations: map[string]string{"version": "1.26"}, } flags := cmd.Flags() diff --git a/cli/command/secret/cmd.go b/cli/command/secret/cmd.go index 9f8e84345e..55ab054d1b 100644 --- a/cli/command/secret/cmd.go +++ b/cli/command/secret/cmd.go @@ -11,11 +11,11 @@ import ( // nolint: interfacer func NewSecretCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ - Use: "secret", - Short: "Manage Docker secrets", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Tags: map[string]string{"version": "1.25"}, + Use: "secret", + Short: "Manage Docker secrets", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"version": "1.25"}, } cmd.AddCommand( newSecretListCommand(dockerCli), diff --git a/cli/command/service/cmd.go b/cli/command/service/cmd.go index 107abf32d0..0f69f28cdc 100644 --- a/cli/command/service/cmd.go +++ b/cli/command/service/cmd.go @@ -11,11 +11,11 @@ import ( // nolint: interfacer func NewServiceCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ - Use: "service", - Short: "Manage services", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Tags: map[string]string{"version": "1.24"}, + Use: "service", + Short: "Manage services", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"version": "1.24"}, } cmd.AddCommand( newCreateCommand(dockerCli), diff --git a/cli/command/service/logs.go b/cli/command/service/logs.go index 272c68e9f2..e619d74e16 100644 --- a/cli/command/service/logs.go +++ b/cli/command/service/logs.go @@ -48,7 +48,7 @@ func newLogsCommand(dockerCli *command.DockerCli) *cobra.Command { opts.target = args[0] return runLogs(dockerCli, &opts) }, - Tags: map[string]string{"version": "1.29"}, + Annotations: map[string]string{"version": "1.29"}, } flags := cmd.Flags() diff --git a/cli/command/service/rollback.go b/cli/command/service/rollback.go index 375e6d510a..2196815cd8 100644 --- a/cli/command/service/rollback.go +++ b/cli/command/service/rollback.go @@ -21,7 +21,7 @@ func newRollbackCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runRollback(dockerCli, options, args[0]) }, - Tags: map[string]string{"version": "1.31"}, + Annotations: map[string]string{"version": "1.31"}, } flags := cmd.Flags() diff --git a/cli/command/service/update_test.go b/cli/command/service/update_test.go index 69e5fa1b1f..50065e4205 100644 --- a/cli/command/service/update_test.go +++ b/cli/command/service/update_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/docker/cli/internal/test/testutil" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" mounttypes "github.com/docker/docker/api/types/mount" @@ -165,7 +166,7 @@ func TestUpdateDNSConfig(t *testing.T) { // IPv6 flags.Set("dns-add", "2001:db8:abc8::1") // Invalid dns record - assert.EqualError(t, flags.Set("dns-add", "x.y.z.w"), "x.y.z.w is not an ip address") + testutil.ErrorContains(t, flags.Set("dns-add", "x.y.z.w"), "x.y.z.w is not an ip address") // domains with duplicates flags.Set("dns-search-add", "example.com") @@ -173,7 +174,7 @@ func TestUpdateDNSConfig(t *testing.T) { flags.Set("dns-search-add", "example.org") flags.Set("dns-search-rm", "example.org") // Invalid dns search domain - assert.EqualError(t, flags.Set("dns-search-add", "example$com"), "example$com is not a valid domain") + testutil.ErrorContains(t, flags.Set("dns-search-add", "example$com"), "example$com is not a valid domain") flags.Set("dns-option-add", "ndots:9") flags.Set("dns-option-rm", "timeout:3") @@ -362,7 +363,7 @@ func TestUpdateHosts(t *testing.T) { // just hostname should work as well flags.Set("host-rm", "example.net") // bad format error - assert.EqualError(t, flags.Set("host-add", "$example.com$"), `bad format for add-host: "$example.com$"`) + testutil.ErrorContains(t, flags.Set("host-add", "$example.com$"), `bad format for add-host: "$example.com$"`) hosts := []string{"1.2.3.4 example.com", "4.3.2.1 example.org", "2001:db8:abc8::1 example.net"} diff --git a/cli/command/stack/cmd.go b/cli/command/stack/cmd.go index 8d4281cfc6..37d99a902a 100644 --- a/cli/command/stack/cmd.go +++ b/cli/command/stack/cmd.go @@ -10,11 +10,11 @@ import ( // nolint: interfacer func NewStackCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ - Use: "stack", - Short: "Manage Docker stacks", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Tags: map[string]string{"version": "1.25"}, + Use: "stack", + Short: "Manage Docker stacks", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"version": "1.25"}, } cmd.AddCommand( newDeployCommand(dockerCli), @@ -31,6 +31,6 @@ func NewTopLevelDeployCommand(dockerCli command.Cli) *cobra.Command { cmd := newDeployCommand(dockerCli) // Remove the aliases at the top level cmd.Aliases = []string{} - cmd.Tags = map[string]string{"experimental": "", "version": "1.25"} + cmd.Annotations = map[string]string{"experimental": "", "version": "1.25"} return cmd } diff --git a/cli/command/swarm/ca.go b/cli/command/swarm/ca.go index 1c2f2d268b..5535172e59 100644 --- a/cli/command/swarm/ca.go +++ b/cli/command/swarm/ca.go @@ -36,7 +36,7 @@ func newCACommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runCA(dockerCli, cmd.Flags(), opts) }, - Tags: map[string]string{"version": "1.30"}, + Annotations: map[string]string{"version": "1.30"}, } flags := cmd.Flags() diff --git a/cli/command/swarm/cmd.go b/cli/command/swarm/cmd.go index d2793f6b91..bea8190a2c 100644 --- a/cli/command/swarm/cmd.go +++ b/cli/command/swarm/cmd.go @@ -11,11 +11,11 @@ import ( // nolint: interfacer func NewSwarmCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ - Use: "swarm", - Short: "Manage Swarm", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Tags: map[string]string{"version": "1.24"}, + Use: "swarm", + Short: "Manage Swarm", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"version": "1.24"}, } cmd.AddCommand( newInitCommand(dockerCli), diff --git a/cli/command/swarm/testdata/update-noargs.golden b/cli/command/swarm/testdata/update-noargs.golden index 381c0ccf1f..a2ce75897c 100644 --- a/cli/command/swarm/testdata/update-noargs.golden +++ b/cli/command/swarm/testdata/update-noargs.golden @@ -8,6 +8,7 @@ Flags: --cert-expiry duration Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s) --dispatcher-heartbeat duration Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s) --external-ca external-ca Specifications of one or more certificate signing endpoints + -h, --help help for update --max-snapshots uint Number of additional Raft snapshots to retain --snapshot-interval uint Number of log entries between Raft snapshots (default 10000) --task-history-limit int Task history retention limit (default 5) diff --git a/cli/command/system/df.go b/cli/command/system/df.go index 5146482f0e..0677801bc3 100644 --- a/cli/command/system/df.go +++ b/cli/command/system/df.go @@ -26,7 +26,7 @@ func newDiskUsageCommand(dockerCli *command.DockerCli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runDiskUsage(dockerCli, opts) }, - Tags: map[string]string{"version": "1.25"}, + Annotations: map[string]string{"version": "1.25"}, } flags := cmd.Flags() diff --git a/cli/command/system/prune.go b/cli/command/system/prune.go index d76d995e37..e777501d89 100644 --- a/cli/command/system/prune.go +++ b/cli/command/system/prune.go @@ -37,7 +37,7 @@ func newPruneCommand(dockerCli command.Cli) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { return runPrune(dockerCli, options) }, - Tags: map[string]string{"version": "1.25"}, + Annotations: map[string]string{"version": "1.25"}, } flags := cmd.Flags() diff --git a/cli/command/volume/cmd.go b/cli/command/volume/cmd.go index cf6e61dfb7..b2a552ae35 100644 --- a/cli/command/volume/cmd.go +++ b/cli/command/volume/cmd.go @@ -9,11 +9,11 @@ import ( // NewVolumeCommand returns a cobra command for `volume` subcommands func NewVolumeCommand(dockerCli command.Cli) *cobra.Command { cmd := &cobra.Command{ - Use: "volume COMMAND", - Short: "Manage volumes", - Args: cli.NoArgs, - RunE: command.ShowHelp(dockerCli.Err()), - Tags: map[string]string{"version": "1.21"}, + Use: "volume COMMAND", + Short: "Manage volumes", + Args: cli.NoArgs, + RunE: command.ShowHelp(dockerCli.Err()), + Annotations: map[string]string{"version": "1.21"}, } cmd.AddCommand( newCreateCommand(dockerCli), diff --git a/cli/command/volume/prune.go b/cli/command/volume/prune.go index abbbff3982..7db81117b8 100644 --- a/cli/command/volume/prune.go +++ b/cli/command/volume/prune.go @@ -35,7 +35,7 @@ func NewPruneCommand(dockerCli command.Cli) *cobra.Command { fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed))) return nil }, - Tags: map[string]string{"version": "1.25"}, + Annotations: map[string]string{"version": "1.25"}, } flags := cmd.Flags() diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index e6ab2a8bf8..2214a13c3c 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -88,6 +88,7 @@ func setFlagErrorFunc(dockerCli *command.DockerCli, cmd *cobra.Command, flags *p } func setHelpFunc(dockerCli *command.DockerCli, cmd *cobra.Command, flags *pflag.FlagSet, opts *cliflags.ClientOptions) { + defaultHelpFunc := cmd.HelpFunc() cmd.SetHelpFunc(func(ccmd *cobra.Command, args []string) { initializeDockerCli(dockerCli, flags, opts) if err := isSupported(ccmd, dockerCli); err != nil { @@ -96,10 +97,7 @@ func setHelpFunc(dockerCli *command.DockerCli, cmd *cobra.Command, flags *pflag. } hideUnsupportedFeatures(ccmd, dockerCli) - - if err := ccmd.Help(); err != nil { - ccmd.Println(err) - } + defaultHelpFunc(ccmd, args) }) } @@ -225,13 +223,13 @@ func hideUnsupportedFeatures(cmd *cobra.Command, details versionDetails) { for _, subcmd := range cmd.Commands() { // hide experimental subcommands if !hasExperimental { - if _, ok := subcmd.Tags["experimental"]; ok { + if _, ok := subcmd.Annotations["experimental"]; ok { subcmd.Hidden = true } } // hide subcommands not supported by the server - if subcmdVersion, ok := subcmd.Tags["version"]; ok && versions.LessThan(clientVersion, subcmdVersion) { + if subcmdVersion, ok := subcmd.Annotations["version"]; ok && versions.LessThan(clientVersion, subcmdVersion) { subcmd.Hidden = true } } @@ -244,10 +242,10 @@ func isSupported(cmd *cobra.Command, details versionDetails) error { // Check recursively so that, e.g., `docker stack ls` returns the same output as `docker stack` for curr := cmd; curr != nil; curr = curr.Parent() { - if cmdVersion, ok := curr.Tags["version"]; ok && versions.LessThan(clientVersion, cmdVersion) { + if cmdVersion, ok := curr.Annotations["version"]; ok && versions.LessThan(clientVersion, cmdVersion) { return fmt.Errorf("%s requires API version %s, but the Docker daemon API version is %s", cmd.CommandPath(), cmdVersion, clientVersion) } - if _, ok := curr.Tags["experimental"]; ok && !hasExperimental { + if _, ok := curr.Annotations["experimental"]; ok && !hasExperimental { return fmt.Errorf("%s is only supported on a Docker daemon with experimental features enabled", cmd.CommandPath()) } } @@ -300,7 +298,7 @@ func isOSTypeSupported(f *pflag.Flag, osType string) bool { // hasTags return true if any of the command's parents has tags func hasTags(cmd *cobra.Command) bool { for curr := cmd; curr != nil; curr = curr.Parent() { - if len(curr.Tags) > 0 { + if len(curr.Annotations) > 0 { return true } } diff --git a/docs/yaml/yaml.go b/docs/yaml/yaml.go index bea3c14cdc..437321a8f6 100644 --- a/docs/yaml/yaml.go +++ b/docs/yaml/yaml.go @@ -53,7 +53,7 @@ func GenYamlTree(cmd *cobra.Command, dir string) error { // GenYamlTreeCustom creates yaml structured ref files func GenYamlTreeCustom(cmd *cobra.Command, dir string, filePrepender func(string) string) error { for _, c := range cmd.Commands() { - if !c.IsAvailableCommand() || c.IsHelpCommand() { + if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { continue } if err := GenYamlTreeCustom(c, dir, filePrepender); err != nil { @@ -103,10 +103,10 @@ func GenYamlCustom(cmd *cobra.Command, w io.Writer) error { } // Check recursively so that, e.g., `docker stack ls` returns the same output as `docker stack` for curr := cmd; curr != nil; curr = curr.Parent() { - if v, ok := curr.Tags["version"]; ok && cliDoc.MinAPIVersion == "" { + if v, ok := curr.Annotations["version"]; ok && cliDoc.MinAPIVersion == "" { cliDoc.MinAPIVersion = v } - if _, ok := curr.Tags["experimental"]; ok && !cliDoc.Experimental { + if _, ok := curr.Annotations["experimental"]; ok && !cliDoc.Experimental { cliDoc.Experimental = true } } @@ -137,7 +137,7 @@ func GenYamlCustom(cmd *cobra.Command, w io.Writer) error { sort.Sort(byName(children)) for _, child := range children { - if !child.IsAvailableCommand() || child.IsHelpCommand() { + if !child.IsAvailableCommand() || child.IsAdditionalHelpTopicCommand() { continue } currentChild := cliDoc.Name + " " + child.Name() @@ -207,7 +207,7 @@ func hasSeeAlso(cmd *cobra.Command) bool { return true } for _, c := range cmd.Commands() { - if !c.IsAvailableCommand() || c.IsHelpCommand() { + if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { continue } return true