Skip to content

Commit

Permalink
Merge pull request #1953 from BlackHole1/improve-docs
Browse files Browse the repository at this point in the history
docs(flag): add `UseShortOptionHandling` description
  • Loading branch information
Juneezee authored Jul 17, 2024
2 parents 937cfe9 + 3bc73ed commit 127cf54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions docs/v2/examples/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ See full list of flags at https://pkg.go.dev/github.com/urfave/cli/v2

For bool flags you can specify the flag multiple times to get a count(e.g -v -v -v or -vvv)

> If you want to support the `-vvv` flag, you need to set `App.UseShortOptionHandling`.
<!-- {
"args": ["&#45;&#45;foo", "&#45;&#45;foo"],
"output": "count 2"
"args": ["&#45;&#45;foo", "&#45;&#45;foo", "&#45;fff", "&#45;f"],
"output": "count 6"
} -->
```go
package main
Expand All @@ -123,10 +125,12 @@ func main() {
var count int

app := &cli.App{
UseShortOptionHandling: true,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "foo",
Usage: "foo greeting",
Aliases: []string{"f"},
Count: &count,
},
},
Expand Down
8 changes: 6 additions & 2 deletions docs/v3/examples/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ See full list of flags at https://pkg.go.dev/github.com/urfave/cli/v3

For bool flags you can specify the flag multiple times to get a count(e.g -v -v -v or -vvv)

> If you want to support the `-vvv` flag, you need to set `Command.UseShortOptionHandling`.
<!-- {
"args": ["&#45;&#45;foo", "&#45;&#45;foo"],
"output": "count 2"
"args": ["&#45;&#45;foo", "&#45;&#45;foo", "&#45;fff"],
"output": "count 5"
} -->
```go
package main
Expand All @@ -126,10 +128,12 @@ func main() {
var count int

cmd := &cli.Command{
UseShortOptionHandling: true,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "foo",
Usage: "foo greeting",
Aliases: []string{"f"},
Config: cli.BoolConfig{
Count: &count,
},
Expand Down

0 comments on commit 127cf54

Please sign in to comment.