add final checks on option values
This commit is contained in:
+6
-2
@@ -57,8 +57,7 @@ func (opt *cliOptionStringMap) getTemplate() string {
|
||||
return opt.makeOptTemplate(true, "key=value")
|
||||
}
|
||||
|
||||
func (opt *cliOptionStringMap) parse(parser cliParser, argIndex int, valuePtr *string) (skipNextArg bool, err error) {
|
||||
var value string
|
||||
func (opt *cliOptionStringMap) 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 {
|
||||
@@ -90,6 +89,11 @@ func (opt *cliOptionStringMap) parse(parser cliParser, argIndex int, valuePtr *s
|
||||
return
|
||||
}
|
||||
|
||||
func (opt *cliOptionStringMap) finalCheck(cliValue string) (err error) {
|
||||
currentValue, _ := opt.getTargetVar()
|
||||
return opt.getBase().checkValue(cliValue, currentValue)
|
||||
}
|
||||
|
||||
func (cli *CliParser) AddStringMapOpt(name, short string, targetVar *map[string]string, defaultValue map[string]string, description string, aliases ...string) OptReference {
|
||||
aliases = cli.checkAlreadyUsedNames(name, short, aliases)
|
||||
opt := &cliOptionStringMap{
|
||||
|
||||
Reference in New Issue
Block a user