add final checks on option values
This commit is contained in:
+6
-2
@@ -63,8 +63,7 @@ func parseIntRange(value string) (min int, max int, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (opt *cliOptionIntArray) parse(parser cliParser, argIndex int, valuePtr *string) (skipNextArg bool, err error) {
|
||||
var optValue string
|
||||
func (opt *cliOptionIntArray) parse(parser cliParser, argIndex int, valuePtr *string) (skipNextArg bool, optValue string, err error) {
|
||||
if optValue, skipNextArg, err = opt.fetchOptionValue(parser, argIndex, valuePtr); err == nil {
|
||||
var boxedValue any
|
||||
if boxedValue, err = opt.getSpecialValue(parser, optValue, opt.targetVar); err == nil {
|
||||
@@ -98,6 +97,11 @@ func (opt *cliOptionIntArray) parse(parser cliParser, argIndex int, valuePtr *st
|
||||
return
|
||||
}
|
||||
|
||||
func (opt *cliOptionIntArray) finalCheck(cliValue string) (err error) {
|
||||
currentValue, _ := opt.getTargetVar()
|
||||
return opt.getBase().checkValue(cliValue, currentValue)
|
||||
}
|
||||
|
||||
func (cli *CliParser) AddIntArrayOpt(name, short string, targetVar *[]int, defaultValue []int, description string, aliases ...string) OptReference {
|
||||
aliases = cli.checkAlreadyUsedNames(name, short, aliases)
|
||||
opt := &cliOptionIntArray{
|
||||
|
||||
Reference in New Issue
Block a user