[agent-wdd] 小小新增部分内容
This commit is contained in:
@@ -8,36 +8,21 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "wdd",
|
||||
Short: "wdd应用程序是wdd封装的NB工具",
|
||||
Long: `使用golang的强大特性,加上wdd的高超技术,\n打造一个方便、高效、适用于各种LINUX系统的瑞士军刀工具\n 尽情享用!`,
|
||||
Long: `使用golang的强大特性,加上 WDD 的高超技术,打造一个方便、高效、适用于各种LINUX系统的瑞士军刀工具!
|
||||
尽情享用! 尽情享用! 尽情享用!`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Do Stuff Here
|
||||
},
|
||||
}
|
||||
var cfgFile = ""
|
||||
var userLicense = ""
|
||||
var projectBase = ""
|
||||
|
||||
func init() {
|
||||
|
||||
cobra.OnInitialize(config.InitConfig)
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
|
||||
rootCmd.PersistentFlags().StringVarP(&projectBase, "projectbase", "b", "",
|
||||
"base project directory eg. github.com/spf13/")
|
||||
rootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "Author name for copyright attribution")
|
||||
rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "Name of license for the project (can provide `licensetext` in config)")
|
||||
rootCmd.PersistentFlags().Bool("viper", true, "Use Viper for configuration")
|
||||
viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))
|
||||
viper.BindPFlag("projectbase", rootCmd.PersistentFlags().Lookup("projectbase"))
|
||||
viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper"))
|
||||
viper.SetDefault("author", "Esdeath Wang(zeaslity@gamil.com)")
|
||||
viper.SetDefault("license", "apache")
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
@@ -110,7 +95,7 @@ func Execute() {
|
||||
// 10. download命令
|
||||
downloadCmd := &cobra.Command{
|
||||
Use: "download",
|
||||
Short: "文件下载管理",
|
||||
Short: "文件下载,直接下载 [url] [dest_path]",
|
||||
}
|
||||
|
||||
addDownloadSubcommands(downloadCmd)
|
||||
@@ -125,6 +110,7 @@ func Execute() {
|
||||
// c.Usage()
|
||||
// })
|
||||
|
||||
// 自定义实现 打印全部的命令
|
||||
printAllCommands(cmd.Root(), os.Stdout)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user