@ -297,13 +297,14 @@ func TestParseMultiString(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . StringFlag { Name : "serve, s" } ,
cli . StringFlag { Name : "serve, s" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . String ( "serve" ) != "10" {
if ctx . String ( "serve" ) != "10" {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ctx . String ( "s" ) != "10" {
if ctx . String ( "s" ) != "10" {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
} ) . Run ( [ ] string { "run" , "-s" , "10" } )
} ) . Run ( [ ] string { "run" , "-s" , "10" } )
}
}
@ -314,13 +315,14 @@ func TestParseMultiStringFromEnv(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . StringFlag { Name : "count, c" , EnvVar : "APP_COUNT" } ,
cli . StringFlag { Name : "count, c" , EnvVar : "APP_COUNT" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . String ( "count" ) != "20" {
if ctx . String ( "count" ) != "20" {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ctx . String ( "c" ) != "20" {
if ctx . String ( "c" ) != "20" {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
} ) . Run ( [ ] string { "run" } )
} ) . Run ( [ ] string { "run" } )
}
}
@ -330,13 +332,14 @@ func TestParseMultiStringSlice(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . StringSliceFlag { Name : "serve, s" , Value : & cli . StringSlice { } } ,
cli . StringSliceFlag { Name : "serve, s" , Value : & cli . StringSlice { } } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ! reflect . DeepEqual ( ctx . StringSlice ( "serve" ) , [ ] string { "10" , "20" } ) {
if ! reflect . DeepEqual ( ctx . StringSlice ( "serve" ) , [ ] string { "10" , "20" } ) {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ! reflect . DeepEqual ( ctx . StringSlice ( "s" ) , [ ] string { "10" , "20" } ) {
if ! reflect . DeepEqual ( ctx . StringSlice ( "s" ) , [ ] string { "10" , "20" } ) {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
} ) . Run ( [ ] string { "run" , "-s" , "10" , "-s" , "20" } )
} ) . Run ( [ ] string { "run" , "-s" , "10" , "-s" , "20" } )
}
}
@ -348,13 +351,14 @@ func TestParseMultiStringSliceFromEnv(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . StringSliceFlag { Name : "intervals, i" , Value : & cli . StringSlice { } , EnvVar : "APP_INTERVALS" } ,
cli . StringSliceFlag { Name : "intervals, i" , Value : & cli . StringSlice { } , EnvVar : "APP_INTERVALS" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ! reflect . DeepEqual ( ctx . StringSlice ( "intervals" ) , [ ] string { "20" , "30" , "40" } ) {
if ! reflect . DeepEqual ( ctx . StringSlice ( "intervals" ) , [ ] string { "20" , "30" , "40" } ) {
t . Errorf ( "main name not set from env" )
t . Errorf ( "main name not set from env" )
}
}
if ! reflect . DeepEqual ( ctx . StringSlice ( "i" ) , [ ] string { "20" , "30" , "40" } ) {
if ! reflect . DeepEqual ( ctx . StringSlice ( "i" ) , [ ] string { "20" , "30" , "40" } ) {
t . Errorf ( "short name not set from env" )
t . Errorf ( "short name not set from env" )
}
}
return nil
} ,
} ,
} ) . Run ( [ ] string { "run" } )
} ) . Run ( [ ] string { "run" } )
}
}
@ -364,13 +368,14 @@ func TestParseMultiInt(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . IntFlag { Name : "serve, s" } ,
cli . IntFlag { Name : "serve, s" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . Int ( "serve" ) != 10 {
if ctx . Int ( "serve" ) != 10 {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ctx . Int ( "s" ) != 10 {
if ctx . Int ( "s" ) != 10 {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" , "-s" , "10" } )
a . Run ( [ ] string { "run" , "-s" , "10" } )
@ -382,13 +387,14 @@ func TestParseMultiIntFromEnv(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . IntFlag { Name : "timeout, t" , EnvVar : "APP_TIMEOUT_SECONDS" } ,
cli . IntFlag { Name : "timeout, t" , EnvVar : "APP_TIMEOUT_SECONDS" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . Int ( "timeout" ) != 10 {
if ctx . Int ( "timeout" ) != 10 {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ctx . Int ( "t" ) != 10 {
if ctx . Int ( "t" ) != 10 {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" } )
a . Run ( [ ] string { "run" } )
@ -399,13 +405,14 @@ func TestParseMultiIntSlice(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . IntSliceFlag { Name : "serve, s" , Value : & cli . IntSlice { } } ,
cli . IntSliceFlag { Name : "serve, s" , Value : & cli . IntSlice { } } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ! reflect . DeepEqual ( ctx . IntSlice ( "serve" ) , [ ] int { 10 , 20 } ) {
if ! reflect . DeepEqual ( ctx . IntSlice ( "serve" ) , [ ] int { 10 , 20 } ) {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ! reflect . DeepEqual ( ctx . IntSlice ( "s" ) , [ ] int { 10 , 20 } ) {
if ! reflect . DeepEqual ( ctx . IntSlice ( "s" ) , [ ] int { 10 , 20 } ) {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
} ) . Run ( [ ] string { "run" , "-s" , "10" , "-s" , "20" } )
} ) . Run ( [ ] string { "run" , "-s" , "10" , "-s" , "20" } )
}
}
@ -417,13 +424,14 @@ func TestParseMultiIntSliceFromEnv(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . IntSliceFlag { Name : "intervals, i" , Value : & cli . IntSlice { } , EnvVar : "APP_INTERVALS" } ,
cli . IntSliceFlag { Name : "intervals, i" , Value : & cli . IntSlice { } , EnvVar : "APP_INTERVALS" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ! reflect . DeepEqual ( ctx . IntSlice ( "intervals" ) , [ ] int { 20 , 30 , 40 } ) {
if ! reflect . DeepEqual ( ctx . IntSlice ( "intervals" ) , [ ] int { 20 , 30 , 40 } ) {
t . Errorf ( "main name not set from env" )
t . Errorf ( "main name not set from env" )
}
}
if ! reflect . DeepEqual ( ctx . IntSlice ( "i" ) , [ ] int { 20 , 30 , 40 } ) {
if ! reflect . DeepEqual ( ctx . IntSlice ( "i" ) , [ ] int { 20 , 30 , 40 } ) {
t . Errorf ( "short name not set from env" )
t . Errorf ( "short name not set from env" )
}
}
return nil
} ,
} ,
} ) . Run ( [ ] string { "run" } )
} ) . Run ( [ ] string { "run" } )
}
}
@ -433,13 +441,14 @@ func TestParseMultiFloat64(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . Float64Flag { Name : "serve, s" } ,
cli . Float64Flag { Name : "serve, s" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . Float64 ( "serve" ) != 10.2 {
if ctx . Float64 ( "serve" ) != 10.2 {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ctx . Float64 ( "s" ) != 10.2 {
if ctx . Float64 ( "s" ) != 10.2 {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" , "-s" , "10.2" } )
a . Run ( [ ] string { "run" , "-s" , "10.2" } )
@ -451,13 +460,14 @@ func TestParseMultiFloat64FromEnv(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . Float64Flag { Name : "timeout, t" , EnvVar : "APP_TIMEOUT_SECONDS" } ,
cli . Float64Flag { Name : "timeout, t" , EnvVar : "APP_TIMEOUT_SECONDS" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . Float64 ( "timeout" ) != 15.5 {
if ctx . Float64 ( "timeout" ) != 15.5 {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ctx . Float64 ( "t" ) != 15.5 {
if ctx . Float64 ( "t" ) != 15.5 {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" } )
a . Run ( [ ] string { "run" } )
@ -468,13 +478,14 @@ func TestParseMultiBool(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . BoolFlag { Name : "serve, s" } ,
cli . BoolFlag { Name : "serve, s" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . Bool ( "serve" ) != true {
if ctx . Bool ( "serve" ) != true {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ctx . Bool ( "s" ) != true {
if ctx . Bool ( "s" ) != true {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" , "--serve" } )
a . Run ( [ ] string { "run" , "--serve" } )
@ -486,13 +497,14 @@ func TestParseMultiBoolFromEnv(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . BoolFlag { Name : "debug, d" , EnvVar : "APP_DEBUG" } ,
cli . BoolFlag { Name : "debug, d" , EnvVar : "APP_DEBUG" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . Bool ( "debug" ) != true {
if ctx . Bool ( "debug" ) != true {
t . Errorf ( "main name not set from env" )
t . Errorf ( "main name not set from env" )
}
}
if ctx . Bool ( "d" ) != true {
if ctx . Bool ( "d" ) != true {
t . Errorf ( "short name not set from env" )
t . Errorf ( "short name not set from env" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" } )
a . Run ( [ ] string { "run" } )
@ -503,13 +515,14 @@ func TestParseMultiBoolT(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . BoolTFlag { Name : "serve, s" } ,
cli . BoolTFlag { Name : "serve, s" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . BoolT ( "serve" ) != true {
if ctx . BoolT ( "serve" ) != true {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ctx . BoolT ( "s" ) != true {
if ctx . BoolT ( "s" ) != true {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" , "--serve" } )
a . Run ( [ ] string { "run" , "--serve" } )
@ -521,13 +534,14 @@ func TestParseMultiBoolTFromEnv(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . BoolTFlag { Name : "debug, d" , EnvVar : "APP_DEBUG" } ,
cli . BoolTFlag { Name : "debug, d" , EnvVar : "APP_DEBUG" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ctx . BoolT ( "debug" ) != false {
if ctx . BoolT ( "debug" ) != false {
t . Errorf ( "main name not set from env" )
t . Errorf ( "main name not set from env" )
}
}
if ctx . BoolT ( "d" ) != false {
if ctx . BoolT ( "d" ) != false {
t . Errorf ( "short name not set from env" )
t . Errorf ( "short name not set from env" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" } )
a . Run ( [ ] string { "run" } )
@ -556,13 +570,14 @@ func TestParseGeneric(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . GenericFlag { Name : "serve, s" , Value : & Parser { } } ,
cli . GenericFlag { Name : "serve, s" , Value : & Parser { } } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ! reflect . DeepEqual ( ctx . Generic ( "serve" ) , & Parser { "10" , "20" } ) {
if ! reflect . DeepEqual ( ctx . Generic ( "serve" ) , & Parser { "10" , "20" } ) {
t . Errorf ( "main name not set" )
t . Errorf ( "main name not set" )
}
}
if ! reflect . DeepEqual ( ctx . Generic ( "s" ) , & Parser { "10" , "20" } ) {
if ! reflect . DeepEqual ( ctx . Generic ( "s" ) , & Parser { "10" , "20" } ) {
t . Errorf ( "short name not set" )
t . Errorf ( "short name not set" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" , "-s" , "10,20" } )
a . Run ( [ ] string { "run" , "-s" , "10,20" } )
@ -574,13 +589,14 @@ func TestParseGenericFromEnv(t *testing.T) {
Flags : [ ] cli . Flag {
Flags : [ ] cli . Flag {
cli . GenericFlag { Name : "serve, s" , Value : & Parser { } , EnvVar : "APP_SERVE" } ,
cli . GenericFlag { Name : "serve, s" , Value : & Parser { } , EnvVar : "APP_SERVE" } ,
} ,
} ,
Action : func ( ctx * cli . Context ) {
Action : func ( ctx * cli . Context ) error {
if ! reflect . DeepEqual ( ctx . Generic ( "serve" ) , & Parser { "20" , "30" } ) {
if ! reflect . DeepEqual ( ctx . Generic ( "serve" ) , & Parser { "20" , "30" } ) {
t . Errorf ( "main name not set from env" )
t . Errorf ( "main name not set from env" )
}
}
if ! reflect . DeepEqual ( ctx . Generic ( "s" ) , & Parser { "20" , "30" } ) {
if ! reflect . DeepEqual ( ctx . Generic ( "s" ) , & Parser { "20" , "30" } ) {
t . Errorf ( "short name not set from env" )
t . Errorf ( "short name not set from env" )
}
}
return nil
} ,
} ,
}
}
a . Run ( [ ] string { "run" } )
a . Run ( [ ] string { "run" } )