Skip to content

Commit

Permalink
Add example for flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
ronelliott committed Dec 28, 2023
1 parent f6b68e4 commit 051e459
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ Flags can be added to a generated command by calling the `WithFlags` function wi
| WithStringVar | Add a `string` flag with only a long name. |
| WithStringVarP | Add a `string` flag with a long and short name. |

### Example

```go
greeting := "hello!"
quantity := 1
cmd, err := snek.NewCommand(
snek.WithFlag(
snek.WithStringVarP(&greeting, "greeting", "g", greeting, "The greeting to use"),
snek.WithStringVarP(&quantity, "quantity", "q", quantity, "The quantity of times to greet"),
),
// ...
)
```

## Complete Example

```go
Expand Down

0 comments on commit 051e459

Please sign in to comment.