visually shorten logic
This commit is contained in:
parent
f00f35ce8c
commit
9293f5b3cc
10
context.go
10
context.go
@ -294,12 +294,10 @@ 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())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user