Add Help Command to Agent WDD CLI
- Implemented a new 'help' command in the root command - Configured the help command to use the default usage template - Integrated the help command into the root command's available subcommands
This commit is contained in:
@@ -111,6 +111,18 @@ func Execute() {
|
||||
}
|
||||
addDownloadSubcommands(downloadCmd)
|
||||
|
||||
helpCmd := &cobra.Command{
|
||||
Use: "help",
|
||||
Short: "帮助信息",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// 在你的命令执行函数中
|
||||
cmd.Root().SetHelpFunc(func(c *cobra.Command, s []string) {
|
||||
// 直接使用默认帮助模板
|
||||
c.Usage()
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
// 添加所有根命令
|
||||
rootCmd.AddCommand(
|
||||
baseCmd,
|
||||
@@ -123,6 +135,7 @@ func Execute() {
|
||||
versionCmd,
|
||||
configCmd,
|
||||
downloadCmd,
|
||||
helpCmd,
|
||||
)
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user