chore(cmd): add subcommands in one call (#819)
This commit is contained in:
parent
7113694ab5
commit
407ced6405
@ -44,12 +44,12 @@ func NewCmdCluster() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add subcommands
|
// add subcommands
|
||||||
cmd.AddCommand(NewCmdClusterCreate())
|
cmd.AddCommand(NewCmdClusterCreate(),
|
||||||
cmd.AddCommand(NewCmdClusterStart())
|
NewCmdClusterStart(),
|
||||||
cmd.AddCommand(NewCmdClusterStop())
|
NewCmdClusterStop(),
|
||||||
cmd.AddCommand(NewCmdClusterDelete())
|
NewCmdClusterDelete(),
|
||||||
cmd.AddCommand(NewCmdClusterList())
|
NewCmdClusterList(),
|
||||||
cmd.AddCommand(NewCmdClusterEdit())
|
NewCmdClusterEdit())
|
||||||
|
|
||||||
// add flags
|
// add flags
|
||||||
|
|
||||||
|
@ -41,8 +41,7 @@ func NewCmdConfig() *cobra.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(NewCmdConfigInit())
|
cmd.AddCommand(NewCmdConfigInit(), NewCmdConfigMigrate())
|
||||||
cmd.AddCommand(NewCmdConfigMigrate())
|
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,7 @@ func NewCmdKubeconfig() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add subcommands
|
// add subcommands
|
||||||
cmd.AddCommand(NewCmdKubeconfigGet())
|
cmd.AddCommand(NewCmdKubeconfigGet(), NewCmdKubeconfigMerge())
|
||||||
cmd.AddCommand(NewCmdKubeconfigMerge())
|
|
||||||
|
|
||||||
// add flags
|
// add flags
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ func NewCmdNode() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add subcommands
|
// add subcommands
|
||||||
cmd.AddCommand(NewCmdNodeCreate())
|
cmd.AddCommand(NewCmdNodeCreate(),
|
||||||
cmd.AddCommand(NewCmdNodeStart())
|
NewCmdNodeStart(),
|
||||||
cmd.AddCommand(NewCmdNodeStop())
|
NewCmdNodeStop(),
|
||||||
cmd.AddCommand(NewCmdNodeDelete())
|
NewCmdNodeDelete(),
|
||||||
cmd.AddCommand(NewCmdNodeList())
|
NewCmdNodeList(),
|
||||||
cmd.AddCommand(NewCmdNodeEdit())
|
NewCmdNodeEdit())
|
||||||
|
|
||||||
// add flags
|
// add flags
|
||||||
|
|
||||||
|
@ -44,11 +44,11 @@ func NewCmdRegistry() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add subcommands
|
// add subcommands
|
||||||
cmd.AddCommand(NewCmdRegistryCreate())
|
cmd.AddCommand(NewCmdRegistryCreate(),
|
||||||
cmd.AddCommand(NewCmdRegistryStart())
|
NewCmdRegistryStart(),
|
||||||
cmd.AddCommand(NewCmdRegistryStop())
|
NewCmdRegistryStop(),
|
||||||
cmd.AddCommand(NewCmdRegistryDelete())
|
NewCmdRegistryDelete(),
|
||||||
cmd.AddCommand(NewCmdRegistryList())
|
NewCmdRegistryList())
|
||||||
|
|
||||||
// add flags
|
// add flags
|
||||||
|
|
||||||
|
64
cmd/root.go
64
cmd/root.go
@ -86,40 +86,38 @@ All Nodes of a k3d cluster are part of the same docker network.`,
|
|||||||
rootCmd.Flags().BoolVar(&flags.version, "version", false, "Show k3d and default k3s version")
|
rootCmd.Flags().BoolVar(&flags.version, "version", false, "Show k3d and default k3s version")
|
||||||
|
|
||||||
// add subcommands
|
// add subcommands
|
||||||
rootCmd.AddCommand(NewCmdCompletion(rootCmd))
|
rootCmd.AddCommand(NewCmdCompletion(rootCmd),
|
||||||
rootCmd.AddCommand(cluster.NewCmdCluster())
|
cluster.NewCmdCluster(),
|
||||||
rootCmd.AddCommand(kubeconfig.NewCmdKubeconfig())
|
kubeconfig.NewCmdKubeconfig(),
|
||||||
rootCmd.AddCommand(node.NewCmdNode())
|
node.NewCmdNode(),
|
||||||
rootCmd.AddCommand(image.NewCmdImage())
|
image.NewCmdImage(),
|
||||||
rootCmd.AddCommand(cfg.NewCmdConfig())
|
cfg.NewCmdConfig(),
|
||||||
rootCmd.AddCommand(registry.NewCmdRegistry())
|
registry.NewCmdRegistry(),
|
||||||
rootCmd.AddCommand(debug.NewCmdDebug())
|
debug.NewCmdDebug(),
|
||||||
|
&cobra.Command{
|
||||||
rootCmd.AddCommand(&cobra.Command{
|
Use: "version",
|
||||||
Use: "version",
|
Short: "Show k3d and default k3s version",
|
||||||
Short: "Show k3d and default k3s version",
|
Long: "Show k3d and default k3s version",
|
||||||
Long: "Show k3d and default k3s version",
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
printVersion()
|
||||||
printVersion()
|
},
|
||||||
},
|
},
|
||||||
})
|
&cobra.Command{
|
||||||
|
Use: "runtime-info",
|
||||||
rootCmd.AddCommand(&cobra.Command{
|
Short: "Show runtime information",
|
||||||
Use: "runtime-info",
|
Long: "Show some information about the runtime environment (e.g. docker info)",
|
||||||
Short: "Show runtime information",
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
Long: "Show some information about the runtime environment (e.g. docker info)",
|
info, err := runtimes.SelectedRuntime.Info()
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
if err != nil {
|
||||||
info, err := runtimes.SelectedRuntime.Info()
|
l.Log().Fatalln(err)
|
||||||
if err != nil {
|
}
|
||||||
l.Log().Fatalln(err)
|
err = yaml.NewEncoder(os.Stdout).Encode(info)
|
||||||
}
|
if err != nil {
|
||||||
err = yaml.NewEncoder(os.Stdout).Encode(info)
|
l.Log().Fatalln(err)
|
||||||
if err != nil {
|
}
|
||||||
l.Log().Fatalln(err)
|
},
|
||||||
}
|
Hidden: true,
|
||||||
},
|
})
|
||||||
Hidden: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
cobra.OnInitialize(initLogging, initRuntime)
|
cobra.OnInitialize(initLogging, initRuntime)
|
||||||
|
Loading…
Reference in New Issue
Block a user