docker / cli

The Docker CLI
Apache License 2.0
4.94k stars 1.93k forks source link

The experimental commands are displayed in non experimental environment. #1417

Open yihyunyi opened 6 years ago

yihyunyi commented 6 years ago

Description

Steps to reproduce the issue:

$ docker
....
Management Commands:
  config      Manage Docker configs
  container   Manage containers
  image       Manage images
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes
$ docker -H
flag needs an argument: 'H' in -H
See 'docker --help'.
....
Management Commands:
  checkpoint  Manage checkpoints
  config      Manage Docker configs
  container   Manage containers
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Describe the results you received: When i tried to use some options like '-H' without needed argument, some experimental commands like 'checkpoint' displayed.

Describe the results you expected: The experimental commands have to hide in non experimental environments.

It looks unlike in /cli/cmd/docker/docker.go's a function setFlagErrorFunc(), a function setHelpFunc() calls hideUnsupportedFeatures()

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) {
        if err := initializeDockerCli(dockerCli, flags, opts); err != nil {
            ccmd.Println(err)
            return
        }
        if err := isSupported(ccmd, dockerCli); err != nil {
            ccmd.Println(err)
            return
        }

        hideUnsupportedFeatures(ccmd, dockerCli)
        defaultHelpFunc(ccmd, args)
    })
}

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Docker version 17.05.0-ce, build 89658be
Docker version 18.06.1-ce, build e68fc7a

Output of docker info:

(paste your output here)

Additional environment details (AWS, VirtualBox, physical, etc.):

thaJeztah commented 6 years ago

Thanks for reporting; are you interested in opening a pull request for this?

bsousaa commented 1 year ago

We need some investigation to confirm if this is still an issue.