in pkg/cmd/ns.go [76:103]
func NewCmdNamespace(streams genericclioptions.IOStreams) *cobra.Command {
o := NewNamespaceOptions(streams)
cmd := &cobra.Command{
Use: "ns [new-namespace] [flags]",
Short: "View or set the current namespace",
Example: fmt.Sprintf(namespaceExample, "kubectl"),
SilenceUsage: true,
RunE: func(c *cobra.Command, args []string) error {
if err := o.Complete(c, args); err != nil {
return err
}
if err := o.Validate(); err != nil {
return err
}
if err := o.Run(); err != nil {
return err
}
return nil
},
}
cmd.Flags().BoolVar(&o.listNamespaces, "list", o.listNamespaces, "if true, print the list of all namespaces in the current KUBECONFIG")
o.configFlags.AddFlags(cmd.Flags())
return cmd
}