https://github.com/unsafe-risk/broccoli
Broccoli: CLI Package for Go
https://github.com/unsafe-risk/broccoli
cli command-line golang zero-dependencies
Last synced: 23 days ago
JSON representation
Broccoli: CLI Package for Go
- Host: GitHub
- URL: https://github.com/unsafe-risk/broccoli
- Owner: unsafe-risk
- License: cc0-1.0
- Created: 2022-08-19T10:27:06.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-27T06:32:21.000Z (over 2 years ago)
- Last Synced: 2025-05-07T22:44:09.525Z (23 days ago)
- Topics: cli, command-line, golang, zero-dependencies
- Language: Go
- Homepage: https://pkg.go.dev/gopkg.eu.org/broccoli
- Size: 75.2 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/unsafe-risk/broccoli/blob/main/LICENSE)
[](https://github.com/unsafe-risk/broccoli/actions/workflows/go-test.yml)
[](https://pkg.go.dev/gopkg.eu.org/broccoli)# broccoli
Broccoli: [CLI](https://en.wikipedia.org/wiki/Command-line_interface) Package for Go
## Usage
```go
package mainimport (
"fmt""gopkg.eu.org/broccoli"
)type Config struct {
_ struct{} `version:"0.0.1" command:"hello" about:"Test App"`
Name string `flag:"name" alias:"n" required:"true" about:"Your name"`Sub *SubCommand `subcommand:"sub"`
}type SubCommand struct {
_ struct{} `command:"sub" longabout:"Test Sub Command"`
Name string `flag:"name" alias:"n" required:"true" about:"Your name"`
}func main() {
var cfg Config
_ = broccoli.BindOSArgs(&cfg)if cfg.Sub != nil {
fmt.Printf("Hello %s from sub command\n", cfg.Sub.Name)
return
}fmt.Printf("Hello %s from main command\n", cfg.Name)
}
``````
$ hello --help
hello 0.0.1
Test AppUsage:
hello [OPTIONS] --name [ARGUEMENTS]Options:
-n, --name Your name (required)
-h, --help Print this help message and exitCommands:
sub Test Sub Command$ hello --name World
Hello World from main command$ hello sub --name World
Hello World from sub command
```## Installation
```bash
go get -u gopkg.eu.org/broccoli
```