Tweaks to Int64Flag PR

This commit is contained in:
Dan Buch 2016-06-16 10:14:28 -04:00
parent 5c7cca7f16
commit 537f5beb66
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC
3 changed files with 4 additions and 6 deletions

View File

@ -7,6 +7,7 @@
- `./runtests` test runner with coverage tracking by default - `./runtests` test runner with coverage tracking by default
- testing on OS X - testing on OS X
- testing on Windows - testing on Windows
- `Int64Flag` type and supporting code
### Changed ### Changed
- Use spaces for alignment in help/usage output instead of tabs, making the - Use spaces for alignment in help/usage output instead of tabs, making the

View File

@ -13,7 +13,7 @@ func TestNewContext(t *testing.T) {
set.Float64("myflag64", float64(17), "doc") set.Float64("myflag64", float64(17), "doc")
globalSet := flag.NewFlagSet("test", 0) globalSet := flag.NewFlagSet("test", 0)
globalSet.Int("myflag", 42, "doc") globalSet.Int("myflag", 42, "doc")
globalSet.Int("myflagInt64", 42, "doc") globalSet.Int64("myflagInt64", int64(42), "doc")
globalSet.Float64("myflag64", float64(47), "doc") globalSet.Float64("myflag64", float64(47), "doc")
globalCtx := NewContext(nil, globalSet, nil) globalCtx := NewContext(nil, globalSet, nil)
command := Command{Name: "mycommand"} command := Command{Name: "mycommand"}

View File

@ -189,7 +189,7 @@ func (f *IntSlice) Set(value string) error {
// String returns a readable representation of this value (for usage defaults) // String returns a readable representation of this value (for usage defaults)
func (f *IntSlice) String() string { func (f *IntSlice) String() string {
return fmt.Sprintf("%d", *f) return fmt.Sprintf("%#v", *f)
} }
// Value returns the slice of ints set by this flag // Value returns the slice of ints set by this flag
@ -260,7 +260,7 @@ func (f *Int64Slice) Set(value string) error {
// String returns a readable representation of this value (for usage defaults) // String returns a readable representation of this value (for usage defaults)
func (f *Int64Slice) String() string { func (f *Int64Slice) String() string {
return fmt.Sprintf("%d", *f) return fmt.Sprintf("%#v", *f)
} }
// Value returns the slice of ints set by this flag // Value returns the slice of ints set by this flag
@ -447,7 +447,6 @@ func (f StringFlag) GetName() string {
} }
// IntFlag is a flag that takes an integer // IntFlag is a flag that takes an integer
// Errors if the value provided cannot be parsed
type IntFlag struct { type IntFlag struct {
Name string Name string
Value int Value int
@ -492,7 +491,6 @@ func (f IntFlag) GetName() string {
} }
// Int64Flag is a flag that takes a 64-bit integer // Int64Flag is a flag that takes a 64-bit integer
// Errors if the value provided cannot be parsed
type Int64Flag struct { type Int64Flag struct {
Name string Name string
Value int64 Value int64
@ -582,7 +580,6 @@ func (f DurationFlag) GetName() string {
} }
// Float64Flag is a flag that takes an float value // Float64Flag is a flag that takes an float value
// Errors if the value provided cannot be parsed
type Float64Flag struct { type Float64Flag struct {
Name string Name string
Value float64 Value float64