mirror of https://github.com/docker/cli.git
cli: pass dockerCLI's in/out/err to cobra cmds
Both the DockerCLI and Cobra Commands provide accessors for Input, Output, and Error streams (usually STDIN, STDOUT, STDERR). While we were already passing DockerCLI's Output to Cobra, we were not doing so for the other streams (and were passing none for plugin commands), potentially resulting in DockerCLI output/input to mean something else than a Cobra Command's intput/output/error. This patch sets them to the same streams when constructing the Cobra command. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
d0a4b6f497
commit
fc6be6ad30
|
@ -133,7 +133,9 @@ func newPluginCommand(dockerCli *command.DockerCli, plugin *cobra.Command, meta
|
||||||
}
|
}
|
||||||
opts, flags := cli.SetupPluginRootCommand(cmd)
|
opts, flags := cli.SetupPluginRootCommand(cmd)
|
||||||
|
|
||||||
|
cmd.SetIn(dockerCli.In())
|
||||||
cmd.SetOut(dockerCli.Out())
|
cmd.SetOut(dockerCli.Out())
|
||||||
|
cmd.SetErr(dockerCli.Err())
|
||||||
|
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
plugin,
|
plugin,
|
||||||
|
|
|
@ -51,6 +51,10 @@ func newDockerCommand(dockerCli *command.DockerCli) *cli.TopLevelCommand {
|
||||||
DisableDescriptions: true,
|
DisableDescriptions: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
cmd.SetIn(dockerCli.In())
|
||||||
|
cmd.SetOut(dockerCli.Out())
|
||||||
|
cmd.SetErr(dockerCli.Err())
|
||||||
|
|
||||||
opts, flags, helpCmd = cli.SetupRootCommand(cmd)
|
opts, flags, helpCmd = cli.SetupRootCommand(cmd)
|
||||||
registerCompletionFuncForGlobalFlags(dockerCli, cmd)
|
registerCompletionFuncForGlobalFlags(dockerCli, cmd)
|
||||||
flags.BoolP("version", "v", false, "Print version information and quit")
|
flags.BoolP("version", "v", false, "Print version information and quit")
|
||||||
|
|
Loading…
Reference in New Issue