Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
lemon-mint committed Aug 20, 2022
1 parent bbacb13 commit 1f3d7ee
Showing 1 changed file with 70 additions and 1 deletion.
71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,71 @@
[![GitHub](https://img.shields.io/github/license/unsafe-risk/broccoli?style=for-the-badge)](https://github.com/unsafe-risk/broccoli/blob/main/LICENSE)
[![GitHub Workflow Status (event)](https://img.shields.io/github/workflow/status/unsafe-risk/broccoli/go-test?event=push&style=for-the-badge)](https://github.com/unsafe-risk/broccoli/actions/workflows/go-test.yml)
[![Go Reference](https://img.shields.io/badge/go-reference-%23007d9c?style=for-the-badge&logo=go)](https://pkg.go.dev/v8.run/go/broccoli)

# broccoli
Broccoli: CLI

Broccoli: [CLI](https://en.wikipedia.org/wiki/Command-line_interface) Package for Go

## Usage

```go
package main

import (
"fmt"

"v8.run/go/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 App
Usage:
hello <COMMAND> [OPTIONS] --name <NAME> [ARGUEMENTS]
Options:
-n, --name Your name (required)
-h, --help Print this help message and exit
Commands:
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 v8.run/go/broccoli
```

0 comments on commit 1f3d7ee

Please sign in to comment.