Files
monok8s/clitools/pkg/cmd/root/root.go

42 lines
1.0 KiB
Go

package root
import (
"flag"
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"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/klog/v2"
)
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(
initcmd.NewCmdInit(flags),
checkconfigcmd.NewCmdCheckConfig(),
createcmd.NewCmdCreate(),
applycmd.NewCmdApply(flags),
agentcmd.NewCmdAgent(flags),
internalcmd.NewCmdInternal(),
)
return cmd
}