Skip to content

Commit

Permalink
Merge pull request #82 from vimeo/flags_skip_unhandled_types
Browse files Browse the repository at this point in the history
flags/pflags: skip registering flags on some types
  • Loading branch information
dfinkel authored Jan 29, 2024
2 parents c805913 + 266ab41 commit 273ee56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sources/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,12 @@ func (s *Set) registerFlags(tmpl reflect.Value, ptyp reflect.Type) error {
case stringSet:
s.Flags.Var(flaghelper.NewStringSetFlag(fieldVal.Addr().Interface().(*map[string]struct{})), name, help)
default:
return fmt.Errorf("unhandled type %s", ft)
// Unhandled type. Just keep going.
continue
}
default:
return fmt.Errorf("unhandled type %s", ft)
// Unhandled type. Just keep going.
continue
}
}
return nil
Expand Down
6 changes: 4 additions & 2 deletions sources/pflag/pflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,13 @@ func (s *Set) registerFlags(tmpl reflect.Value, ptyp reflect.Type) error {
f = fieldVal.Addr().Interface()
s.Flags.VarP(flaghelper.NewStringSetFlag(fieldVal.Addr().Interface().(*map[string]struct{})), name, shorthand, help)
default:
return fmt.Errorf("unhandled type %s", ft)
// Unhandled type. Just keep going.
continue
}

default:
return fmt.Errorf("unhandled type %s", ft)
// Unhandled type. Just keep going.
continue
}

v := reflect.ValueOf(f)
Expand Down

0 comments on commit 273ee56

Please sign in to comment.