diff --git a/cli_test.go b/cli_test.go index 2c32ad0..5bcca67 100644 --- a/cli_test.go +++ b/cli_test.go @@ -85,16 +85,17 @@ where: Output destination file Optional report file - -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) ["," ...] Process only the specified pages (comma-separated list) - -c, --config Alternate configuration file - -l, --log(s) ["," ...] Logging options (comma-separated list) - -V, --var(s) ["," ...] Define one or more comma separated variables for the actions context (multiple allowed) - -n, --input-name Input file name when source comes from stdin - -d, --work-dir Work directory - --attempts Attempts for retrying failed operations (default: "1") + -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) ["," ...] Process only the specified pages (comma-separated list) + -c, --config Alternate configuration file + -l, --log(s) ["," ...] Logging options (comma-separated list) + --var(s) ["," ...] Define one or more comma separated variables for the actions context (multiple allowed) + -n, --input-name Input file name when source comes from stdin + -d, --work-dir Work directory + --attempts Attempts for retrying failed operations (default: "1") ` var cli CliParser var gd GlobalData diff --git a/opt-base.go b/opt-base.go index 1e41a6a..90eabf3 100644 --- a/opt-base.go +++ b/opt-base.go @@ -13,6 +13,7 @@ type cliOptionBase struct { description string isArray bool hidden bool + alreadySeen bool specialValues map[string]SpecialValueFunc incompatibleWith []string } diff --git a/opt-int-array.go b/opt-int-array.go index 2d9c993..162e75f 100644 --- a/opt-int-array.go +++ b/opt-int-array.go @@ -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 { diff --git a/opt-string-array.go b/opt-string-array.go index 520a55c..b66eba6 100644 --- a/opt-string-array.go +++ b/opt-string-array.go @@ -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, ",") } diff --git a/opt-string-map.go b/opt-string-map.go index 6756d73..014d11a 100644 --- a/opt-string-map.go +++ b/opt-string-map.go @@ -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, ",") {