add final checks on option values
This commit is contained in:
+5
-2
@@ -36,8 +36,7 @@ func (opt *cliOptionString) getTemplate() string {
|
||||
return opt.makeOptTemplate(false, stringTypeName)
|
||||
}
|
||||
|
||||
func (opt *cliOptionString) parse(parser cliParser, argIndex int, valuePtr *string) (skipNextArg bool, err error) {
|
||||
var value string
|
||||
func (opt *cliOptionString) parse(parser cliParser, argIndex int, valuePtr *string) (skipNextArg bool, value string, err error) {
|
||||
if value, skipNextArg, err = opt.fetchOptionValue(parser, argIndex, valuePtr); err == nil {
|
||||
var boxedValue any
|
||||
if boxedValue, err = opt.getSpecialValue(parser, value, opt.targetVar); err == nil {
|
||||
@@ -56,6 +55,10 @@ func (opt *cliOptionString) parse(parser cliParser, argIndex int, valuePtr *stri
|
||||
}
|
||||
return
|
||||
}
|
||||
func (opt *cliOptionString) finalCheck(cliValue string) (err error) {
|
||||
currentValue, _ := opt.getTargetVar()
|
||||
return opt.getBase().checkValue(cliValue, currentValue)
|
||||
}
|
||||
|
||||
func (cli *CliParser) AddStringOpt(name, short string, targetVar *string, defaultValue string, description string, aliases ...string) OptReference {
|
||||
if cli.optionExists(name, short, aliases) {
|
||||
|
||||
Reference in New Issue
Block a user