xflags
xflags copied to clipboard
Incorrect handling of negative numerical flags
Problem
I don't think the current implementation handles numerical flags (e.g: xflags.Int
, xflags.Int64
, xflags.Float64
, etc) that are assigned to negative values.
For example:
$ test-cli --numerical-flag=-10
test-cli: --numerical-flag: no value specified for flag: --numerical-flag
Here is a PR that adds some test cases to reproduce the problem along with a very naive attempt to fix the problem https://github.com/cavaliergopher/xflags/pull/3
From that branch (without the fix commit):
$ go test -vet=off ./...
--- FAIL: TestFloat64 (0.00s)
xflags_test.go:79: xflags: --foo-negative: no value specified for flag: --foo-negative
--- FAIL: TestInt64 (0.00s)
xflags_test.go:79: xflags: --foo-negative: no value specified for flag: --foo-negative
FAIL
FAIL github.com/cavaliergopher/xflags 0.601s
FAIL