diff --git a/pkg/cmd/cli/cli.go b/pkg/cmd/cli/cli.go index 00af69fddbd5..4d4ec3f0dc55 100644 --- a/pkg/cmd/cli/cli.go +++ b/pkg/cmd/cli/cli.go @@ -96,19 +96,21 @@ func NewCommandCLI(name, fullName string) *cobra.Command { func NewCmdKubectl(name string) *cobra.Command { flags := pflag.NewFlagSet("", pflag.ContinueOnError) f := clientcmd.New(flags) - cmd := kubecmd.NewKubectlCommand(f.Factory, os.Stdin, os.Stdout, os.Stderr) - cmd.Aliases = []string{"kubectl"} - cmd.Use = name - cmd.Short = "Kubernetes cluster management via kubectl" - cmd.Long = cmd.Long + "\n\nThis command is provided for direct management of the Kubernetes cluster OpenShift runs on." + out := os.Stdout + cmds := kubecmd.NewKubectlCommand(f.Factory, os.Stdin, os.Stdout, os.Stderr) + cmds.Aliases = []string{"kubectl"} + cmds.Use = name + cmds.Short = "Kubernetes cluster management via kubectl" + cmds.Long = cmds.Long + "\n\nThis command is provided for direct management of the Kubernetes cluster OpenShift runs on." flags.VisitAll(func(flag *pflag.Flag) { - if f := cmd.PersistentFlags().Lookup(flag.Name); f == nil { - cmd.PersistentFlags().AddFlag(flag) + if f := cmds.PersistentFlags().Lookup(flag.Name); f == nil { + cmds.PersistentFlags().AddFlag(flag) } else { glog.V(6).Infof("already registered flag %s", flag.Name) } }) - return cmd + cmds.AddCommand(cmd.NewCmdOptions(f, out)) + return cmds } // applyToCreate injects the deprecation notice about for 'apply' command into diff --git a/pkg/cmd/openshift/openshift.go b/pkg/cmd/openshift/openshift.go index 5c12acf4b9a9..1b144578a069 100644 --- a/pkg/cmd/openshift/openshift.go +++ b/pkg/cmd/openshift/openshift.go @@ -10,6 +10,7 @@ import ( "github.com/openshift/origin/pkg/cmd/admin" "github.com/openshift/origin/pkg/cmd/cli" + "github.com/openshift/origin/pkg/cmd/cli/cmd" "github.com/openshift/origin/pkg/cmd/experimental/buildchain" "github.com/openshift/origin/pkg/cmd/experimental/bundlesecret" "github.com/openshift/origin/pkg/cmd/experimental/generate" @@ -125,6 +126,7 @@ func newExperimentalCommand(parentName, name string) *cobra.Command { } f := clientcmd.New(experimental.PersistentFlags()) + out := os.Stdout subName := fmt.Sprintf("%s %s", parentName, name) experimental.AddCommand(project.NewCmdNewProject(f, subName, "new-project")) @@ -135,5 +137,6 @@ func newExperimentalCommand(parentName, name string) *cobra.Command { experimental.AddCommand(exregistry.NewCmdRegistry(f, subName, "registry", os.Stdout)) experimental.AddCommand(buildchain.NewCmdBuildChain(f, subName, "build-chain")) experimental.AddCommand(bundlesecret.NewCmdBundleSecret(f, subName, "bundle-secret", os.Stdout)) + experimental.AddCommand(cmd.NewCmdOptions(f, out)) return experimental }