Skip to content

Incorrect handling of negative numerical flags #4

@alloveras

Description

@alloveras

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 #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions