From 7a703dccc49e2d7df9c47ddefdf28edc2a013061 Mon Sep 17 00:00:00 2001 From: zeaslity Date: Thu, 27 Feb 2025 14:26:07 +0800 Subject: [PATCH] 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 --- agent-wdd/cmd/root.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/agent-wdd/cmd/root.go b/agent-wdd/cmd/root.go index 3cf0a6d..7343a75 100644 --- a/agent-wdd/cmd/root.go +++ b/agent-wdd/cmd/root.go @@ -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 {