普通网友 2018-03-07 09:59
浏览 67
已采纳

Cobra子命令默认调用帮助

I want sub command to print out the Help menu if no argument or flags is passed (The main command does this by default).

For example, the main command without any arguments or flags:

chris@pop-os:~$ ./tk
Command line application to deploy

Usage:
  tk [command]

Available Commands:
  addon       Install packages
  cluster     Used to create cloud infrastructures
  help        Help about any command

Flags:
      --config string   config file (default is $HOME/.tk8.yaml)
  -h, --help            help for tk
  -t, --toggle          Help message for toggle

Use "tk [command] --help" for more information about a command.

I want subcommand like "tk addon" to also return it's own help menu if no arguments or flags is entered, currently it only gives a blank line.

addon code :

var addonCmd = &cobra.Command{
    Use:   "addon",
Short: "Install addon packages",
Long: `Install additional packages`,
Run: func(cmd *cobra.Command, args []string) {

        }
    },
}
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 关于用matlab进行光束整形的问题
      • ¥15 vs code编译器 C语言刚学,想的有点复杂
      • ¥15 航班订票系统函数无法运行
      • ¥20 VS2022无法启动程序,如何解决?(语言-c++|开发工具-visual studio)
      • ¥15 c语言可以做出完整的吗有人看看吗
      • ¥15 电脑流氓插件处理方法
      • ¥15 问一下这个可调恒流源电路用哪个电源接口比较好,想用tapec接口仅作为电源接口这个引脚怎么连啊
      • ¥30 Abaqus做建模的时候网格没办法收敛是为什么?
      • ¥15 车牌识别摄像镜头,httppost,nodejs
      • ¥20 腾讯云托管与本地测试 GET请求获取返回值 完全不同