File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,7 @@ type errRequiredFlags struct {
55
55
}
56
56
57
57
func (e * errRequiredFlags ) Error () string {
58
- numberOfMissingFlags := len (e .missingFlags )
59
- if numberOfMissingFlags == 1 {
58
+ if len (e .missingFlags ) == 1 {
60
59
return fmt .Sprintf ("Required flag %q not set" , e .missingFlags [0 ])
61
60
}
62
61
joinedMissingFlags := strings .Join (e .missingFlags , ", " )
Original file line number Diff line number Diff line change @@ -169,3 +169,15 @@ func TestMultiErrorErrorsCopy(t *testing.T) {
169
169
me := newMultiError (errList ... )
170
170
expect (t , errList , me .Errors ())
171
171
}
172
+
173
+ func TestErrRequiredFlags_Error (t * testing.T ) {
174
+ missingFlags := []string {"flag1" , "flag2" }
175
+ err := & errRequiredFlags {missingFlags : missingFlags }
176
+ expectedMsg := "Required flags \" flag1, flag2\" not set"
177
+ expect (t , expectedMsg , err .Error ())
178
+
179
+ missingFlags = []string {"flag1" }
180
+ err = & errRequiredFlags {missingFlags : missingFlags }
181
+ expectedMsg = "Required flag \" flag1\" not set"
182
+ expect (t , expectedMsg , err .Error ())
183
+ }
You can’t perform that action at this time.
0 commit comments