Files
ProjectOctopus/agent-wdd/cmd/Download.go
zeaslity 72bc56b5e5 Enhance Zsh and Config Commands, Update Network Configuration
- 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
2025-02-27 14:20:05 +08:00

45 lines
957 B
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 (
"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)
}
// 根据需求补充其他子命令的添加函数...