use strings.Join
This commit is contained in:
parent
cdc7af744e
commit
01d5cfab70
12
context.go
12
context.go
@ -308,16 +308,8 @@ func checkRequiredFlags(flags []Flag, set *flag.FlagSet) error {
|
|||||||
return fmt.Errorf("Required flag %q not set", missingFlags[0])
|
return fmt.Errorf("Required flag %q not set", missingFlags[0])
|
||||||
}
|
}
|
||||||
if numberOfMissingFlags >= 2 {
|
if numberOfMissingFlags >= 2 {
|
||||||
var missingFlagsOutput string
|
joinedMissingFlags := strings.Join(missingFlags, ", ")
|
||||||
for idx, f := range missingFlags {
|
return fmt.Errorf("Required flags %q not set", joinedMissingFlags)
|
||||||
// if not the last item, append with a ", "
|
|
||||||
if idx != numberOfMissingFlags-1 {
|
|
||||||
missingFlagsOutput = fmt.Sprintf("%s%s, ", missingFlagsOutput, f)
|
|
||||||
} else {
|
|
||||||
missingFlagsOutput = fmt.Sprintf("%s%s", missingFlagsOutput, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fmt.Errorf("Required flags %q not set", missingFlagsOutput)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user