Added some ctl boilerplate
This commit is contained in:
41
clitools/pkg/cmd/root/root.go
Normal file
41
clitools/pkg/cmd/root/root.go
Normal file
@@ -0,0 +1,41 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user