- Implemented comprehensive Zsh installation command with multiple network scenarios - Added 'config show' subcommand to display agent configuration - Updated version command to print version information - Modified Network configuration to clarify internet connectivity status - Improved download utility with additional file existence checks - Updated agent-wdd rules and documentation
45 lines
957 B
Go
45 lines
957 B
Go
package cmd
|
||
|
||
import (
|
||
"agent-wdd/log"
|
||
"agent-wdd/utils"
|
||
"fmt"
|
||
|
||
"github.com/spf13/cobra"
|
||
)
|
||
|
||
// 示例:添加download子命令
|
||
func addDownloadSubcommands(cmd *cobra.Command) {
|
||
proxyCmd := &cobra.Command{
|
||
Use: "proxy [url] [dest]",
|
||
Short: "使用代理下载",
|
||
Args: cobra.ExactArgs(2),
|
||
Run: func(cmd *cobra.Command, args []string) {
|
||
fmt.Printf("Downloading with proxy: %s -> %s\n", args[0], args[1])
|
||
},
|
||
}
|
||
|
||
cmd.Run = func(cmd *cobra.Command, args []string) {
|
||
if len(args) == 0 {
|
||
log.Error("请输入下载地址")
|
||
return
|
||
} else if len(args) == 1 {
|
||
args = append(args, ".")
|
||
}
|
||
|
||
log.Info("Downloading without proxy: %s -> %s\n", args[0], args[1])
|
||
|
||
downloadOk, resultLog := utils.DownloadFile(args[0], args[1])
|
||
if !downloadOk {
|
||
log.Error("下载失败: %s", resultLog)
|
||
} else {
|
||
log.Info("下载成功: %s", args[1])
|
||
}
|
||
|
||
}
|
||
|
||
cmd.AddCommand(proxyCmd)
|
||
}
|
||
|
||
// 根据需求补充其他子命令的添加函数...
|