visually shorten logic

This commit is contained in:
Lynn Cyrin 2019-07-14 21:00:16 -07:00
parent f00f35ce8c
commit 9293f5b3cc
No known key found for this signature in database
GPG Key ID: EE9CCB427DFEC897

View File

@ -294,14 +294,12 @@ func checkRequiredFlags(flags []Flag, set *flag.FlagSet) error {
}) })
for _, f := range flags { for _, f := range flags {
if rf, ok := f.(RequiredFlag); ok { if rf, ok := f.(RequiredFlag); ok && rf.IsRequired() {
if rf.IsRequired() {
key := strings.Split(f.GetName(), ",")[0] key := strings.Split(f.GetName(), ",")[0]
if !visited[key] { if !visited[key] {
return fmt.Errorf("Required flag %q not set", f.GetName()) return fmt.Errorf("Required flag %q not set", f.GetName())
} }
} }
} }
}
return nil return nil
} }