https://github.com/dharmeshkakadia/cobra-example
minimal example of cobra app
https://github.com/dharmeshkakadia/cobra-example
cli cobra example golang
Last synced: 7 days ago
JSON representation
minimal example of cobra app
- Host: GitHub
- URL: https://github.com/dharmeshkakadia/cobra-example
- Owner: dharmeshkakadia
- License: apache-2.0
- Created: 2017-09-07T06:21:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-12T07:14:51.000Z (over 8 years ago)
- Last Synced: 2025-08-13T20:05:07.221Z (6 months ago)
- Topics: cli, cobra, example, golang
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 56
- Watchers: 2
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cobra-example
=============
An example application built with [cobra](https://github.com/spf13/cobra)
# Steps
1. Install cobra
`go get github.com/spf13/cobra/cobra`
2. Initialize cobra-example application
`$GOPATH/bin/cobra init github.com/dharmeshkakadia/cobra-example`
3. Add `hello` and `bye` sub commands to our example app
`$GOPATH/bin/cobra add hello`
`$GOPATH/bin/cobra add bye`
4. Edit `cmd/hello.go`, `cmd/bye.go` and `main.go` to reflect the command description and logic required.
5. Run `main.go`. You would see full help and subcommands
```
go 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
```