Closed Kaweees closed 2 months ago
Hey @Kaweees , just to confirm, do you mean you would write code like this:
var args struct {
X int
}
arg.MustParse(&args)
and then on the command line you would write ./myprogram --x 0xFF
and x
would get the value 255? Seems very reasonable to me.
Yes, that would be splendid. It would be nice if it would default to interpreting a decimal number if the number is unable to be parsed as a hexadecmial number.
Well I think this already works!
package main
import (
"fmt"
"github.com/alexflint/go-arg"
)
func main() {
var args struct {
X int
}
arg.MustParse(&args)
fmt.Println(args.X)
}
$ go run *.go --x 0xFF
255
$ go run *.go --x 123
123
Going to close this for now.
I would love to have the ability to specify pass in hexadecimal value(s) as arguments and have them be parsed as decimal values