package root import ( "flag" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/klog/v2" agentcmd "undecided.project/monok8s/pkg/cmd/agent" applycmd "undecided.project/monok8s/pkg/cmd/apply" checkconfigcmd "undecided.project/monok8s/pkg/cmd/checkconfig" createcmd "undecided.project/monok8s/pkg/cmd/create" initcmd "undecided.project/monok8s/pkg/cmd/initcmd" internalcmd "undecided.project/monok8s/pkg/cmd/internal" versioncmd "undecided.project/monok8s/pkg/cmd/version" ) func NewRootCmd() *cobra.Command { flags := genericclioptions.NewConfigFlags(true) cmd := &cobra.Command{ Use: "ctl", Short: "MonoK8s control tool", SilenceUsage: true, SilenceErrors: true, PersistentPreRun: func(*cobra.Command, []string) { klog.InitFlags(nil) _ = flag.Set("logtostderr", "true") }, } flags.AddFlags(cmd.PersistentFlags()) cmd.AddCommand( versioncmd.NewCmdVersion(), initcmd.NewCmdInit(flags), checkconfigcmd.NewCmdCheckConfig(), createcmd.NewCmdCreate(), applycmd.NewCmdApply(flags), agentcmd.NewCmdAgent(flags), internalcmd.NewCmdInternal(), ) return cmd }