value of a container option (e.g. array) is reset to empty on first specification
This commit is contained in:
parent
f55e9cea82
commit
ac8d5fa3a9
@ -85,13 +85,14 @@ where:
|
||||
<dest> Output destination file
|
||||
<report> Optional report file
|
||||
<options>
|
||||
-V, --verbose Print verbose output (default: "0")
|
||||
-o, --print-ocr Print the OCR output to stderr
|
||||
-s, --save-clip Save the image clips as PNG files (alias: save-clips)
|
||||
-t, --trace Enable trace mode for detailed logging
|
||||
-p, --page(s) <num>["," ...] Process only the specified pages (comma-separated list)
|
||||
-c, --config <file> Alternate configuration file
|
||||
-l, --log(s) <string>["," ...] Logging options (comma-separated list)
|
||||
-V, --var(s) <key=value>["," ...] Define one or more comma separated variables for the actions context (multiple allowed)
|
||||
--var(s) <key=value>["," ...] Define one or more comma separated variables for the actions context (multiple allowed)
|
||||
-n, --input-name <string> Input file name when source comes from stdin
|
||||
-d, --work-dir <dir> Work directory
|
||||
--attempts <num> Attempts for retrying failed operations (default: "1")
|
||||
|
||||
@ -13,6 +13,7 @@ type cliOptionBase struct {
|
||||
description string
|
||||
isArray bool
|
||||
hidden bool
|
||||
alreadySeen bool
|
||||
specialValues map[string]SpecialValueFunc
|
||||
incompatibleWith []string
|
||||
}
|
||||
|
||||
@ -76,6 +76,10 @@ func (opt *cliOptionIntArray) parse(parser cliParser, argIndex int, valuePtr *st
|
||||
err = errInvalidOptionValue(opt.name, boxedValue, "num-array")
|
||||
}
|
||||
} else {
|
||||
if !opt.alreadySeen {
|
||||
*opt.targetVar = []int{}
|
||||
opt.alreadySeen = true
|
||||
}
|
||||
for value := range strings.SplitSeq(optValue, ",") {
|
||||
var minRange, maxRange int
|
||||
if minRange, maxRange, err = parseIntRange(value); err == nil {
|
||||
|
||||
@ -55,6 +55,8 @@ func (opt *cliOptionStringArray) parse(parser cliParser, argIndex int, valuePtr
|
||||
} else {
|
||||
err = errInvalidOptionValue(opt.name, boxedValue, "array of string")
|
||||
}
|
||||
} else if opt.alreadySeen {
|
||||
*opt.targetVar = append(*opt.targetVar, strings.Split(value, ",")...)
|
||||
} else {
|
||||
*opt.targetVar = strings.Split(value, ",")
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ func (opt *cliOptionStringMap) parse(parser cliParser, argIndex int, valuePtr *s
|
||||
err = errInvalidOptionValue(opt.name, boxedValue, "map of string")
|
||||
}
|
||||
} else {
|
||||
if dict == nil {
|
||||
if dict == nil || !opt.alreadySeen {
|
||||
dict = make(map[string]string)
|
||||
}
|
||||
for value := range strings.SplitSeq(value, ",") {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user