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
- testing on OS X
- testing on Windows
- `Int64Flag` type and supporting code
### Changed
- 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")
globalSet := flag.NewFlagSet("test", 0)
globalSet.Int("myflag", 42, "doc")
globalSet.Int("myflagInt64", 42, "doc")
globalSet.Int64("myflagInt64", int64(42), "doc")
globalSet.Float64("myflag64", float64(47), "doc")
globalCtx := NewContext(nil, globalSet, nil)
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)
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
@ -260,7 +260,7 @@ func (f *Int64Slice) Set(value string) error {
// String returns a readable representation of this value (for usage defaults)
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
@ -447,7 +447,6 @@ func (f StringFlag) GetName() string {
}
// IntFlag is a flag that takes an integer
// Errors if the value provided cannot be parsed
type IntFlag struct {
Name string
Value int
@ -492,7 +491,6 @@ func (f IntFlag) GetName() string {
}
// Int64Flag is a flag that takes a 64-bit integer
// Errors if the value provided cannot be parsed
type Int64Flag struct {
Name string
Value int64
@ -582,7 +580,6 @@ func (f DurationFlag) GetName() string {
}
// Float64Flag is a flag that takes an float value
// Errors if the value provided cannot be parsed
type Float64Flag struct {
Name string
Value float64