Allow explicitly setting boolean options in Go cli parser

Matches C parser
This commit is contained in:
Kovid Goyal 2025-04-28 11:54:51 +05:30
parent 39bf612071
commit d7fb143ee0
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 45 additions and 12 deletions

View file

@ -55,7 +55,13 @@ func (self *Command) parse_args(ctx *Context, args []string) error {
}
if has_val {
if !needs_arg {
return &ParseError{Message: fmt.Sprintf("The option: :yellow:`%s` does not take values", opt_str)}
if opt.OptionType == BoolOption {
if err := opt.add_value(opt_val); err != nil {
return err
}
} else {
return &ParseError{Message: fmt.Sprintf("The option: :yellow:`%s` does not take values", opt_str)}
}
}
return opt.add_value(opt_val)
} else if needs_arg {