The cobra package
cobra
is a very handy and popular Go package that allows you to develop command line utilities with commands, subcommands, and aliases. If you have ever used hugo
, docker
, or kubectl
, you are going to realize immediately what the cobra
package does, as all these tools are developed using cobra
. Commands can have one or more aliases, which is very handy when you want to please both amateur and experienced users. cobra
also supports persistent flags and local flags, which are flags that are available to all commands and flags that are available to given commands only, respectively. Also, by default, cobra
uses viper
for parsing its command line arguments.
All Cobra projects follow the same development pattern. You use the Cobra command line utility, you create commands, and then you make the desired changes to the generated Go source code files in order to implement the desired functionality. Depending on the complexity of your utility, you might need to make lots...