diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index b9734453ff..d781b688ca 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -103,15 +103,6 @@ func setupHelpCommand(dockerCli *command.DockerCli, rootCmd, helpCmd *cobra.Comm return err } - // Add a stub entry for every plugin so they are - // included in the help output. If we have no args - // then this is being used for `docker help` and we - // want to include broken plugins, otherwise this is - // `help «foo»` and we do not. - if err := pluginmanager.AddPluginCommandStubs(dockerCli, rootCmd, len(args) == 0); err != nil { - return err - } - if origRunE != nil { return origRunE(c, args) } @@ -135,6 +126,17 @@ func setHelpFunc(dockerCli *command.DockerCli, cmd *cobra.Command, flags *pflag. ccmd.Println(err) return } + + // Add a stub entry for every plugin so they are + // included in the help output. If we have no args + // then this is being used for `docker help` and we + // want to include broken plugins, otherwise this is + // `help «foo»` and we do not. + if err := pluginmanager.AddPluginCommandStubs(dockerCli, ccmd.Root(), len(args) == 0); err != nil { + ccmd.Println(err) + return + } + defaultHelpFunc(ccmd, args) }) } diff --git a/e2e/cli-plugins/help_test.go b/e2e/cli-plugins/help_test.go index c66dfacc0f..f9690fe503 100644 --- a/e2e/cli-plugins/help_test.go +++ b/e2e/cli-plugins/help_test.go @@ -51,4 +51,12 @@ func TestGlobalHelp(t *testing.T) { } assert.Assert(t, found, "Did not find match for %q in `docker help` output", expected) } + + // Running just `docker` (without help) should produce the same thing, except on Stderr + res2 := icmd.RunCmd(run()) + res2.Assert(t, icmd.Expected{ + ExitCode: 0, + }) + assert.Assert(t, is.Equal(res2.Stdout(), "")) + assert.Assert(t, is.Equal(res2.Stderr(), res.Stdout())) }