mirror of https://github.com/docker/cli.git
prevent `tryRunPluginHelp()` execution on non-1st-level commands.
commands comes in the form of `rootCmd 1stCmd 2ndCmd` and the `tryRunPluginHelp()` function takes the command name to run plugin help in the form `docker-<command name>`, if command name matches a plugin name it will display the wrong help message. to make sure we're using 1stCmd level we check if the root command is the same as the command parent. e.g. `docker swarm init --help` ``` docker: is the root command swarm : 1st level command init : 2nd level command --help: is a flag ``` this approach is not taking in consideration if a plugin and 1st level command matches, for example `docker foo` command and `docker-foo` plugin. Signed-off-by: Hernan Garcia <hernandanielg@gmail.com> Signed-off-by: Hernan Garcia <hernan.garcia@percona.com>
This commit is contained in:
parent
dc2eb3bf7c
commit
2e01bdae1b
|
@ -137,7 +137,10 @@ func setHelpFunc(dockerCli command.Cli, cmd *cobra.Command) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) >= 1 {
|
// commands are chained in the form `rootCmd 1stCmd 2ndCmd...`
|
||||||
|
// if RootCmd and ParentCmd are the same
|
||||||
|
// then my command is 1st level command
|
||||||
|
if len(args) >= 1 && ccmd.Root() == ccmd.Parent() {
|
||||||
err := tryRunPluginHelp(dockerCli, ccmd, args)
|
err := tryRunPluginHelp(dockerCli, ccmd, args)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue