backwards compatible RequiredFlag implementation

This commit is contained in:
Lynn Cyrin
2019-07-11 21:53:10 -07:00
parent 922d231891
commit 6a2ae78373
2 changed files with 14 additions and 5 deletions

View File

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