@@ -234,17 +234,18 @@ func ExampleApp_Run_bashComplete_withShortFlag() {
234234 os .Setenv ("SHELL" , "bash" )
235235 os .Args = []string {"greet" , "-" , "--generate-shell-completion" }
236236
237- app := NewApp ()
238- app .Name = "greet"
239- app .EnableShellCompletion = true
240- app .Flags = []Flag {
241- & IntFlag {
242- Name : "other" ,
243- Aliases : []string {"o" },
244- },
245- & StringFlag {
246- Name : "xyz" ,
247- Aliases : []string {"x" },
237+ app := & App {
238+ Name : "greet" ,
239+ EnableShellCompletion : true ,
240+ Flags : []Flag {
241+ & IntFlag {
242+ Name : "other" ,
243+ Aliases : []string {"o" },
244+ },
245+ & StringFlag {
246+ Name : "xyz" ,
247+ Aliases : []string {"x" },
248+ },
248249 },
249250 }
250251
@@ -262,23 +263,24 @@ func ExampleApp_Run_bashComplete_withLongFlag() {
262263 os .Setenv ("SHELL" , "bash" )
263264 os .Args = []string {"greet" , "--s" , "--generate-shell-completion" }
264265
265- app := NewApp ()
266- app .Name = "greet"
267- app .EnableShellCompletion = true
268- app .Flags = []Flag {
269- & IntFlag {
270- Name : "other" ,
271- Aliases : []string {"o" },
272- },
273- & StringFlag {
274- Name : "xyz" ,
275- Aliases : []string {"x" },
276- },
277- & StringFlag {
278- Name : "some-flag,s" ,
279- },
280- & StringFlag {
281- Name : "similar-flag" ,
266+ app := & App {
267+ Name : "greet" ,
268+ EnableShellCompletion : true ,
269+ Flags : []Flag {
270+ & IntFlag {
271+ Name : "other" ,
272+ Aliases : []string {"o" },
273+ },
274+ & StringFlag {
275+ Name : "xyz" ,
276+ Aliases : []string {"x" },
277+ },
278+ & StringFlag {
279+ Name : "some-flag,s" ,
280+ },
281+ & StringFlag {
282+ Name : "similar-flag" ,
283+ },
282284 },
283285 }
284286
@@ -292,26 +294,27 @@ func ExampleApp_Run_bashComplete_withMultipleLongFlag() {
292294 os .Setenv ("SHELL" , "bash" )
293295 os .Args = []string {"greet" , "--st" , "--generate-shell-completion" }
294296
295- app := NewApp ()
296- app .Name = "greet"
297- app .EnableShellCompletion = true
298- app .Flags = []Flag {
299- & IntFlag {
300- Name : "int-flag" ,
301- Aliases : []string {"i" },
302- },
303- & StringFlag {
304- Name : "string" ,
305- Aliases : []string {"s" },
306- },
307- & StringFlag {
308- Name : "string-flag-2" ,
309- },
310- & StringFlag {
311- Name : "similar-flag" ,
312- },
313- & StringFlag {
314- Name : "some-flag" ,
297+ app := & App {
298+ Name : "greet" ,
299+ EnableShellCompletion : true ,
300+ Flags : []Flag {
301+ & IntFlag {
302+ Name : "int-flag" ,
303+ Aliases : []string {"i" },
304+ },
305+ & StringFlag {
306+ Name : "string" ,
307+ Aliases : []string {"s" },
308+ },
309+ & StringFlag {
310+ Name : "string-flag-2" ,
311+ },
312+ & StringFlag {
313+ Name : "similar-flag" ,
314+ },
315+ & StringFlag {
316+ Name : "some-flag" ,
317+ },
315318 },
316319 }
317320
@@ -364,26 +367,27 @@ func ExampleApp_Run_zshComplete() {
364367 os .Args = []string {"greet" , "--generate-shell-completion" }
365368 _ = os .Setenv ("SHELL" , "/usr/bin/zsh" )
366369
367- app := NewApp ()
368- app .Name = "greet"
369- app .EnableShellCompletion = true
370- app .Commands = []* Command {
371- {
372- Name : "describeit" ,
373- Aliases : []string {"d" },
374- Usage : "use it to see a description" ,
375- Description : "This is how we describe describeit the function" ,
376- Action : func (* Context ) error {
377- fmt .Printf ("i like to describe things" )
378- return nil
379- },
380- }, {
381- Name : "next" ,
382- Usage : "next example" ,
383- Description : "more stuff to see when generating bash completion" ,
384- Action : func (* Context ) error {
385- fmt .Printf ("the next example" )
386- return nil
370+ app := & App {
371+ Name : "greet" ,
372+ EnableShellCompletion : true ,
373+ Commands : []* Command {
374+ {
375+ Name : "describeit" ,
376+ Aliases : []string {"d" },
377+ Usage : "use it to see a description" ,
378+ Description : "This is how we describe describeit the function" ,
379+ Action : func (* Context ) error {
380+ fmt .Printf ("i like to describe things" )
381+ return nil
382+ },
383+ }, {
384+ Name : "next" ,
385+ Usage : "next example" ,
386+ Description : "more stuff to see when generating bash completion" ,
387+ Action : func (* Context ) error {
388+ fmt .Printf ("the next example" )
389+ return nil
390+ },
387391 },
388392 },
389393 }
@@ -406,13 +410,14 @@ func ExampleApp_Run_sliceValues() {
406410 "--int64Sclice" , "13,14" , "--int64Sclice" , "15,16" ,
407411 "--intSclice" , "13,14" , "--intSclice" , "15,16" ,
408412 }
409- app := NewApp ()
410- app .Name = "multi_values"
411- app .Flags = []Flag {
412- & StringSliceFlag {Name : "stringSclice" },
413- & Float64SliceFlag {Name : "float64Sclice" },
414- & Int64SliceFlag {Name : "int64Sclice" },
415- & IntSliceFlag {Name : "intSclice" },
413+ app := & App {
414+ Name : "multi_values" ,
415+ Flags : []Flag {
416+ & StringSliceFlag {Name : "stringSclice" },
417+ & Float64SliceFlag {Name : "float64Sclice" },
418+ & Int64SliceFlag {Name : "int64Sclice" },
419+ & IntSliceFlag {Name : "intSclice" },
420+ },
416421 }
417422 app .Action = func (ctx * Context ) error {
418423 for i , v := range ctx .FlagNames () {
@@ -438,19 +443,20 @@ func ExampleApp_Run_mapValues() {
438443 "multi_values" ,
439444 "--stringMap" , "parsed1=parsed two" , "--stringMap" , "parsed3=" ,
440445 }
441- app := NewApp ()
442- app .Name = "multi_values"
443- app .Flags = []Flag {
444- & StringMapFlag {Name : "stringMap" },
445- }
446- app .Action = func (ctx * Context ) error {
447- for i , v := range ctx .FlagNames () {
448- fmt .Printf ("%d-%s %#v\n " , i , v , ctx .StringMap (v ))
449- }
450- fmt .Printf ("notfound %#v\n " , ctx .StringMap ("notfound" ))
451- err := ctx .Err ()
452- fmt .Println ("error:" , err )
453- return err
446+ app := & App {
447+ Name : "multi_values" ,
448+ Flags : []Flag {
449+ & StringMapFlag {Name : "stringMap" },
450+ },
451+ Action : func (ctx * Context ) error {
452+ for i , v := range ctx .FlagNames () {
453+ fmt .Printf ("%d-%s %#v\n " , i , v , ctx .StringMap (v ))
454+ }
455+ fmt .Printf ("notfound %#v\n " , ctx .StringMap ("notfound" ))
456+ err := ctx .Err ()
457+ fmt .Println ("error:" , err )
458+ return err
459+ },
454460 }
455461
456462 _ = app .Run (os .Args )
@@ -2711,8 +2717,9 @@ func TestWhenExitSubCommandWithCodeThenAppQuitUnexpectedly(t *testing.T) {
27112717}
27122718
27132719func newTestApp () * App {
2714- a := NewApp ()
2715- a .Writer = io .Discard
2720+ a := & App {
2721+ Writer : io .Discard ,
2722+ }
27162723 return a
27172724}
27182725
0 commit comments