func AddFlags(fs *pflag.FlagSet, kubectlSubCmd string) { cmd := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, os.Stdout, os.Stderr) fs.AddFlagSet(cmd.LocalFlags()) if kubectlSubCmd == "" { return } for _, child := range cmd.Commands() { if child.Name() == kubectlSubCmd { fs.AddFlagSet(child.LocalFlags()) return } } }
func NewKubectlServer() *Server { cmd := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, os.Stdout, os.Stderr) localFlags := cmd.LocalFlags() localFlags.SetInterspersed(false) return &Server{ name: "kubectl", SimpleUsage: "Kubernetes command line client", Long: "Kubernetes command line client", Run: func(s *Server, args []string) error { cmd.SetArgs(args) return cmd.Execute() }, flags: localFlags, } }
func NewKubectlServer() *Server { // need to use term.StdStreams to get the right IO refs on Windows stdin, stdout, stderr := term.StdStreams() cmd := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), stdin, stdout, stderr) localFlags := cmd.LocalFlags() localFlags.SetInterspersed(false) return &Server{ name: "kubectl", SimpleUsage: "Kubernetes command line client", Long: "Kubernetes command line client", Run: func(s *Server, args []string) error { cmd.SetArgs(args) return cmd.Execute() }, flags: localFlags, } }