Skip to content

Commit

Permalink
docs(flag): add UseShortOptionHandling description
Browse files Browse the repository at this point in the history
Close: #1942

Signed-off-by: Kevin Cui <[email protected]>
  • Loading branch information
BlackHole1 committed Jul 15, 2024
1 parent 937cfe9 commit 090b964
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/v2/examples/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ 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"
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
4 changes: 4 additions & 0 deletions docs/v3/examples/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ 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"
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 090b964

Please sign in to comment.