File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,9 @@ func (in InputInfo) ShortOnly(c byte) InputInfo {
257257 return in .Short (c )
258258}
259259
260+ // Long sets the option long name to the given name. Since an option's long name will be
261+ // the input ID by default, this method is really only necessary when the long name must
262+ // differ from the input ID.
260263func (in InputInfo ) Long (name string ) InputInfo {
261264 in .NameLong = name
262265 return in
Original file line number Diff line number Diff line change @@ -99,6 +99,26 @@ func ExampleInputInfo_WithParser() {
9999 // image.Point{X:3, Y:7}
100100}
101101
102+ func ExampleInputInfo_Long () {
103+ in := cli .New ("example" ).
104+ Help ("example program" ).
105+ Opt (cli .NewOpt ("id1" ).Help ("long name is the id by default" )).
106+ Opt (cli .NewOpt ("id2" ).Long ("long-name" ).Help ("long name is set to something other than the id" ))
107+
108+ _ , err := in .Parse ("-h" )
109+ fmt .Println (err )
110+ // Output:
111+ // example - example program
112+ //
113+ // usage:
114+ // example [options]
115+ //
116+ // options:
117+ // -h, --help Show this help message and exit.
118+ // --id1 <arg> long name is the id by default
119+ // --long-name <arg> long name is set to something other than the id
120+ }
121+
102122func ExampleParseURL () {
103123 in := cli .New ().
104124 Opt (cli .NewOpt ("u" ).WithParser (cli .ParseURL ))
You can’t perform that action at this time.
0 commit comments