Skip to content

Negative numbers do not work with short version of flag #315

@Samyak2

Description

@Samyak2

Minimal reproducible example

package main

import "github.com/alecthomas/kong"

var Cli struct {
	ArgA float64 `short:"a" description:"Argument A"`
}

func main() {
	kong.Parse(&Cli)
}

The long version works as expected:

go run . --arg-a=-10

The short version:

go run . -a=-10

Errors out:

kong-issue-repro: error: --arg-a: expected a float but got "=-10" (string)
exit status 1

Context

I did look at #166 (comment), but there was no info on whether it is expected that the short and long versions behave differently.

I would be willing to contribute a fix if this is an actual bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions