...
1
2
3
4
5 package pflag_test
6
7 import (
8 "fmt"
9
10 "github.com/spf13/pflag"
11 )
12
13 func ExampleShorthandLookup() {
14 name := "verbose"
15 short := name[:1]
16
17 pflag.BoolP(name, short, false, "verbose output")
18
19
20 flag := pflag.ShorthandLookup(short)
21
22 fmt.Println(flag.Name)
23 }
24
25 func ExampleFlagSet_ShorthandLookup() {
26 name := "verbose"
27 short := name[:1]
28
29 fs := pflag.NewFlagSet("Example", pflag.ContinueOnError)
30 fs.BoolP(name, short, false, "verbose output")
31
32
33 flag := fs.ShorthandLookup(short)
34
35 fmt.Println(flag.Name)
36 }
37
View as plain text