【发布时间】:2018-03-21 12:48:22
【问题描述】:
我需要开始使用命令行工具,我有几个问题
我们决定使用 cobra 进行围棋 https://github.com/spf13/cobra
来自帮助:
$ cobra help
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.
Usage:
cobra [command]
Available Commands:
add Add a command to a Cobra Application
help Help about any command
init Initialize a Cobra Application
Flags:
-a, --author string author name for copyright attribution (default "YOUR NAME")
--config string config file (default is $HOME/.cobra.yaml)
-h, --help help for cobra
-l, --license string name of license for the project
--viper use Viper for configuration (default true)
Use "cobra [command] --help" for more information about a command.
我的问题是:
- 命令和标志(可用命令)语义之间的关系/差异是什么……。
- 命令和标志之间是否存在关系
- 单个命令是否应该支持标志
- 如果需要向 x 提供类似 deploy 之类的命令,应该是“deploy -x”
【问题讨论】:
-
1.命令是命令(如 foo)并标记一个标志(如 --foo)。 2. 不。是的命令有标志。 3. ??? 4. ??? (口味问题)。
标签: go command-line command-line-interface