Files
ProjectOctopus/agent-wdd/cmd/Base.go
2025-02-10 15:07:44 +08:00

74 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
// 添加base子命令
func addBaseSubcommands(cmd *cobra.Command) {
// 1.1 docker
dockerCmd := &cobra.Command{
Use: "docker",
Short: "Docker相关操作",
}
addDockerSubcommands(dockerCmd)
// 1.2 dockercompose
dockerComposeCmd := &cobra.Command{
Use: "dockercompose",
Short: "Docker Compose相关操作",
}
addDockerComposeSubcommands(dockerComposeCmd)
// 其他base子命令...
cmd.AddCommand(
dockerCmd,
dockerComposeCmd,
// 其他命令...
)
}
// 添加docker子命令
func addDockerSubcommands(cmd *cobra.Command) {
onlineCmd := &cobra.Command{
Use: "online [version]",
Short: "网络安装Docker",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Installing Docker version: %s\n", args[0])
},
}
removeCmd := &cobra.Command{
Use: "remove",
Short: "卸载Docker",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Removing Docker...")
},
}
localCmd := &cobra.Command{
Use: "local [path]",
Short: "本地安装Docker",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Installing Docker from: %s\n", args[0])
},
}
cmd.AddCommand(onlineCmd, removeCmd, localCmd)
}
func addDockerComposeSubcommands(cmd *cobra.Command) {
}
// addToolsSubcommands 利用本机的yumapt等从网络安装常用的软件
func addToolsSubcommands(cmd *cobra.Command) {
// 检测本机使用的包安装方式为apt还是yum
// 检查本机
//
}