in flags/distribution.go [72:96]
func (d *Distribution) Set(value string) error {
matches := []string{}
for key := range generators {
if strings.HasPrefix(key, value) {
matches = append(matches, key)
}
}
if len(matches) == 0 {
choices := ChoicesString(DistributionChoices())
return fmt.Errorf("%w, want: %s, got: %q", ErrInvalidGenerator, choices, value)
} else if len(matches) > 1 {
sort.Strings(matches)
return fmt.Errorf("%w, ambiguous prefix %q matches: %s", ErrInvalidGenerator, value, ChoicesString(matches))
}
generator := matches[0]
d.Name = generator
d.generator = generators[generator]
return nil
}