This commit is contained in:
Kovid Goyal 2022-12-14 15:45:43 +05:30
parent 80db167abb
commit 928becece4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -35,8 +35,14 @@ func (self *Command) parse_args(ctx *Context, args []string) error {
ambi := make([]string, len(possible_options)) ambi := make([]string, len(possible_options))
for i, o := range possible_options { for i, o := range possible_options {
ambi[i] = o.MatchingAlias(NormalizeOptionName(opt_str), !strings.HasPrefix(opt_str, "--")) ambi[i] = o.MatchingAlias(NormalizeOptionName(opt_str), !strings.HasPrefix(opt_str, "--"))
if ambi[i] == opt_str {
opt = o
break
}
}
if opt == nil {
return &ParseError{Message: fmt.Sprintf("Ambiguous option: :yellow:`%s` could be any of: %s", opt_str, strings.Join(ambi, ", "))}
} }
return &ParseError{Message: fmt.Sprintf("Ambiguous option: :yellow:`%s` could be any of: %s", opt_str, strings.Join(ambi, ", "))}
} }
opt.seen_option = opt_str opt.seen_option = opt_str
needs_arg := opt.needs_argument() needs_arg := opt.needs_argument()