value of a container option (e.g. array) is reset to empty on first specification

This commit is contained in:
2026-03-03 05:58:15 +01:00
parent f55e9cea82
commit ac8d5fa3a9
5 changed files with 19 additions and 11 deletions
+4
View File
@@ -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 {