An example application built with cobra
-
Install cobra
go get github.com/spf13/cobra/cobra -
Initialize cobra-example application
$GOPATH/bin/cobra init github.com/dharmeshkakadia/cobra-example -
Add
helloandbyesub commands to our example app$GOPATH/bin/cobra add hello$GOPATH/bin/cobra add bye -
Edit
cmd/hello.go,cmd/bye.goandmain.goto reflect the command description and logic required. -
Run
main.go. You would see full help and subcommandsgo run main.go This application shows how to create modern CLI applications in go using Cobra CLI library Usage: cobra-example [command] Available Commands: bye says bye hello says hello help Help about any command Flags: --config string config file (default is $HOME/.cobra-example.yaml) -h, --help help for cobra-example -t, --toggle Help message for toggle