Run gofmt

This commit is contained in:
Naveen Gogineni 2022-09-05 08:12:38 -04:00
parent 268cb973f8
commit 069c6bfe4a
2 changed files with 22 additions and 7 deletions

15
flag.go
View File

@ -89,22 +89,37 @@ func (f FlagsByName) Swap(i, j int) {
// this interface be implemented. // this interface be implemented.
type Flag interface { type Flag interface {
fmt.Stringer fmt.Stringer
// Apply Flag settings to the given flag set // Apply Flag settings to the given flag set
Apply(*flag.FlagSet) error Apply(*flag.FlagSet) error
// All possible names for this flag
Names() []string Names() []string
// Whether the flag has been set or not
IsSet() bool IsSet() bool
// whether the flag is a required flag or not
IsRequired() bool IsRequired() bool
// IsVisible returns true if the flag is not hidden, otherwise false // IsVisible returns true if the flag is not hidden, otherwise false
IsVisible() bool IsVisible() bool
// Returns the category of the flag
GetCategory() string GetCategory() string
// GetUsage returns the usage string for the flag // GetUsage returns the usage string for the flag
GetUsage() string GetUsage() string
// GetEnvVars returns the env vars for this flag // GetEnvVars returns the env vars for this flag
GetEnvVars() []string GetEnvVars() []string
// TakesValue returns true if the flag takes a value, otherwise false // TakesValue returns true if the flag takes a value, otherwise false
TakesValue() bool TakesValue() bool
// GetDefaultText returns the default text for this flag // GetDefaultText returns the default text for this flag
GetDefaultText() string GetDefaultText() string
// GetValue returns the flags value as string representation and an empty // GetValue returns the flags value as string representation and an empty
// string if the flag takes no value at all. // string if the flag takes no value at all.
GetValue() string GetValue() string

View File

@ -2384,43 +2384,43 @@ func TestFlagDefaultValue(t *testing.T) {
name: "stringSclice", name: "stringSclice",
flag: &StringSliceFlag{Name: "flag", Value: NewStringSlice("default1", "default2")}, flag: &StringSliceFlag{Name: "flag", Value: NewStringSlice("default1", "default2")},
toParse: []string{"--flag", "parsed"}, toParse: []string{"--flag", "parsed"},
expect: `--flag value (default: "default1", "default2") (accepts multiple inputs)`, expect: `--flag value (default: "default1", "default2") (accepts multiple inputs)`,
}, },
{ {
name: "float64Sclice", name: "float64Sclice",
flag: &Float64SliceFlag{Name: "flag", Value: NewFloat64Slice(1.1, 2.2)}, flag: &Float64SliceFlag{Name: "flag", Value: NewFloat64Slice(1.1, 2.2)},
toParse: []string{"--flag", "13.3"}, toParse: []string{"--flag", "13.3"},
expect: `--flag value (default: 1.1, 2.2) (accepts multiple inputs)`, expect: `--flag value (default: 1.1, 2.2) (accepts multiple inputs)`,
}, },
{ {
name: "int64Sclice", name: "int64Sclice",
flag: &Int64SliceFlag{Name: "flag", Value: NewInt64Slice(1, 2)}, flag: &Int64SliceFlag{Name: "flag", Value: NewInt64Slice(1, 2)},
toParse: []string{"--flag", "13"}, toParse: []string{"--flag", "13"},
expect: `--flag value (default: 1, 2) (accepts multiple inputs)`, expect: `--flag value (default: 1, 2) (accepts multiple inputs)`,
}, },
{ {
name: "intSclice", name: "intSclice",
flag: &IntSliceFlag{Name: "flag", Value: NewIntSlice(1, 2)}, flag: &IntSliceFlag{Name: "flag", Value: NewIntSlice(1, 2)},
toParse: []string{"--flag", "13"}, toParse: []string{"--flag", "13"},
expect: `--flag value (default: 1, 2) (accepts multiple inputs)`, expect: `--flag value (default: 1, 2) (accepts multiple inputs)`,
}, },
{ {
name: "string", name: "string",
flag: &StringFlag{Name: "flag", Value: "default"}, flag: &StringFlag{Name: "flag", Value: "default"},
toParse: []string{"--flag", "parsed"}, toParse: []string{"--flag", "parsed"},
expect: `--flag value (default: "default")`, expect: `--flag value (default: "default")`,
}, },
{ {
name: "bool", name: "bool",
flag: &BoolFlag{Name: "flag", Value: true}, flag: &BoolFlag{Name: "flag", Value: true},
toParse: []string{"--flag", "false"}, toParse: []string{"--flag", "false"},
expect: `--flag (default: true)`, expect: `--flag (default: true)`,
}, },
{ {
name: "uint64", name: "uint64",
flag: &Uint64Flag{Name: "flag", Value: 1}, flag: &Uint64Flag{Name: "flag", Value: 1},
toParse: []string{"--flag", "13"}, toParse: []string{"--flag", "13"},
expect: `--flag value (default: 1)`, expect: `--flag value (default: 1)`,
}, },
} }
for i, v := range cases { for i, v := range cases {