@@ -25,6 +25,7 @@ import (
2525 "flag"
2626 "fmt"
2727 "io"
28+ "log"
2829 "os"
2930 "reflect"
3031 "strings"
@@ -92,7 +93,9 @@ func ExampleApplication_Run() {
9293 },
9394 }
9495
95- app .Run (os .Args )
96+ if err := app .Run (os .Args ); err != nil {
97+ log .Fatal (err )
98+ }
9699 // Output:
97100 // Hello Jeremy
98101}
@@ -115,7 +118,9 @@ func ExampleApplication_Run_quiet() {
115118 },
116119 }
117120
118- app .Run (os .Args )
121+ if err := app .Run (os .Args ); err != nil {
122+ log .Fatal (err )
123+ }
119124 // Output:
120125}
121126
@@ -138,7 +143,9 @@ func ExampleApplication_Run_quietDisabled() {
138143 },
139144 }
140145
141- app .Run (os .Args )
146+ if err := app .Run (os .Args ); err != nil {
147+ log .Fatal (err )
148+ }
142149 // Output:
143150 // Hello Jeremy
144151 // Byebye Jeremy
@@ -164,7 +171,9 @@ func (ts *ApplicationSuite) ExampleApplication_Run_quietInvalid(c *C) {
164171 },
165172 }
166173
167- app .Run (os .Args )
174+ if err := app .Run (os .Args ); err != nil {
175+ log .Fatal (err )
176+ }
168177 c .Assert (stdout .String (), Equals , `Output:
169178<info>greet</> version <comment>0.0.0</>
170179A new cli application
@@ -217,7 +226,9 @@ func (ts *ApplicationSuite) ExampleApplication_Run_appHelp(c *C) {
217226 },
218227 },
219228 }
220- app .Run (os .Args )
229+ if err := app .Run (os .Args ); err != nil {
230+ log .Fatal (err )
231+ }
221232 c .Assert (stdout .String (), Equals , `Output:
222233<info>greet</> version <comment>0.1.0</>
223234A new cli application
@@ -262,7 +273,9 @@ func ExampleApplication_Run_commandHelp() {
262273 },
263274 },
264275 }
265- app .Run (os .Args )
276+ if err := app .Run (os .Args ); err != nil {
277+ log .Fatal (err )
278+ }
266279 // Output:
267280 // <comment>Description:</>
268281 // use it to see a description
@@ -341,7 +354,7 @@ func (ts *ApplicationSuite) TestApp_CommandWithFlagBeforeTerminator(c *C) {
341354 }
342355 app .Commands = []* Command {command }
343356
344- app .Run ([]string {"" , "cmd" , "--option" , "my-option" , "my-arg" , "--" , "--notARealFlag" })
357+ c . Assert ( app .Run ([]string {"" , "cmd" , "--option" , "my-option" , "my-arg" , "--" , "--notARealFlag" }), IsNil )
345358
346359 c .Assert (parsedOption , Equals , "my-option" )
347360 c .Assert (args , NotNil )
@@ -366,7 +379,7 @@ func (ts *ApplicationSuite) TestApp_CommandWithDash(c *C) {
366379 }
367380 app .Commands = []* Command {command }
368381
369- app .Run ([]string {"" , "cmd" , "my-arg" , "-" })
382+ c . Assert ( app .Run ([]string {"" , "cmd" , "my-arg" , "-" }), IsNil )
370383 c .Assert (args , NotNil )
371384 c .Assert (args .Len (), Equals , 2 )
372385 c .Assert (args .Get ("first" ), Equals , "my-arg" )
@@ -390,8 +403,7 @@ func (ts *ApplicationSuite) TestApp_CommandWithNoFlagBeforeTerminator(c *C) {
390403 }
391404 app .Commands = []* Command {command }
392405
393- app .Run ([]string {"" , "cmd" , "my-arg" , "--" , "notAFlagAtAll" })
394-
406+ c .Assert (app .Run ([]string {"" , "cmd" , "my-arg" , "--" , "notAFlagAtAll" }), IsNil )
395407 c .Assert (args .Get ("first" ), Equals , "my-arg" )
396408 c .Assert (args .Get ("second" ), Equals , "notAFlagAtAll" )
397409}
@@ -465,7 +477,7 @@ func (ts *ApplicationSuite) TestApp_Float64Flag(c *C) {
465477 },
466478 }
467479
468- app .Run ([]string {"" , "--height" , "1.93" })
480+ c . Assert ( app .Run ([]string {"" , "--height" , "1.93" }), IsNil )
469481 c .Assert (meters , Equals , 1.93 )
470482}
471483
@@ -493,7 +505,9 @@ func TestApp_ParseSliceFlags(t *testing.T) {
493505 }
494506 app .Commands = []* Command {command }
495507
496- app .Run ([]string {"" , "cmd" , "-p" , "22" , "-p" , "80" , "-ip" , "8.8.8.8" , "-ip" , "8.8.4.4" , "my-first-arg" })
508+ if err := app .Run ([]string {"" , "cmd" , "-p" , "22" , "-p" , "80" , "-ip" , "8.8.8.8" , "-ip" , "8.8.4.4" , "my-first-arg" }); err != nil {
509+ t .Error (err )
510+ }
497511
498512 IntsEquals := func (a , b []int ) bool {
499513 if len (a ) != len (b ) {
@@ -556,7 +570,9 @@ func TestApp_ParseSliceFlagsWithMissingValue(t *testing.T) {
556570 }
557571 app .Commands = []* Command {command }
558572
559- app .Run ([]string {"" , "cmd" , "-a" , "2" , "-str" , "A" , "my-arg" })
573+ if err := app .Run ([]string {"" , "cmd" , "-a" , "2" , "-str" , "A" , "my-arg" }); err != nil {
574+ t .Error (err )
575+ }
560576
561577 var expectedIntSlice = []int {2 }
562578 var expectedStringSlice = []string {"A" }
@@ -784,7 +800,9 @@ func TestAppHelpPrinter(t *testing.T) {
784800 }
785801
786802 app := & Application {}
787- app .Run ([]string {"-h" })
803+ if err := app .Run ([]string {"-h" }); err != nil {
804+ t .Error (err )
805+ }
788806
789807 if wasCalled == false {
790808 t .Errorf ("Help printer expected to be called, but was not" )
@@ -1036,7 +1054,9 @@ func TestApp_Run_Categories(t *testing.T) {
10361054 versionCommand .Hidden = nil
10371055 }()
10381056
1039- app .Run ([]string {"categories" })
1057+ if err := app .Run ([]string {"categories" }); err != nil {
1058+ t .Error (err )
1059+ }
10401060
10411061 expect := commandCategories ([]* commandCategory {
10421062 {
0 commit comments