Cobra is a tool for creating CLI tools in Go.
Framework
Cobra creates CLI tools that are based on commands, args, and flags. The pattern for creating tools using Cobra is generally:
APPNAME COMMAND ARG --FLAG
For example, if we’re using Hugo, we might see:
hugo server --port=1313Where ‘server’ is a command and ‘port’ is a flag. As another example, we might clone a URL with git via:
git clone URL --bareIn this instance, ‘clone’ is a command, ‘URL’ is an arg (we’d supply a real url here), and ‘—bare’ is a flag.
Usage
Cobra provides the cobra-cli program to help bootstrap applications to help develop Cobra applications. To generate the scaffolding for a new app using Cobra, we can run:
cobra-cli init [app]And we can provide flags to this as well, e.g.
cobra-cli init [app] --author "Eric Ekholm eric.ekholm@gmail.com" --license mitFor more info on how to work with the cobra-cli tool, see its README