In the special case where an arg has max: 1, args.Parse would panic when arg was omitted.
Also ensure omitted args retain their Value, if provided.
--- FAIL: TestSingleOptionalArg (0.00s)
panic: runtime error: index out of range [0] with length 0 [recovered]
panic: runtime error: index out of range [0] with length 0
goroutine 15 [running]:
testing.tRunner.func1.2({0x163bc20, 0xc00001c660})
/usr/local/Cellar/go/1.21.4/libexec/src/testing/testing.go:1545 +0x366
testing.tRunner.func1()
/usr/local/Cellar/go/1.21.4/libexec/src/testing/testing.go:1548 +0x630
panic({0x163bc20?, 0xc00001c660?})
/usr/local/Cellar/go/1.21.4/libexec/src/runtime/panic.go:920 +0x270
github.com/urfave/cli/v3.(*ArgumentBase[...]).Parse(0x1729d40, {0xc0003381a0, 0x0?, 0x0})
/Users/josh/src/cli/args.go:136 +0xc88
Testing
Tests added for an omitted arg with max: 1, with and without a default Value.
Release Notes
Optional arguments with arity 1 no longer panic when omitted.
What type of PR is this?
What this PR does / why we need it:
max: 1
,args.Parse
would panic when arg was omitted.Value
, if provided.Testing
Tests added for an omitted arg with
max: 1
, with and without a defaultValue
.Release Notes