From ce1630141e70b2ca599a21fd9494e98b88f25b2d Mon Sep 17 00:00:00 2001 From: Lynn Cyrin Date: Thu, 11 Jul 2019 20:18:52 -0700 Subject: [PATCH] reduce diff??? --- flag.go | 111 +------------------------------------------------------- 1 file changed, 1 insertion(+), 110 deletions(-) diff --git a/flag.go b/flag.go index b4cf6da..de42938 100644 --- a/flag.go +++ b/flag.go @@ -115,22 +115,6 @@ type Generic interface { String() string } -// GenericFlag is the flag type for types implementing Generic -type GenericFlag struct { - Name string - Value Generic - Usage string - EnvVar string - Required bool -} - -// String returns the string representation of the generic flag to display the -// help text to the user (uses the String() method of the generic flag to show -// the value) -func (f GenericFlag) String() string { - return withHints(f.EnvVar, f.Required, fmt.Sprintf("%s%s \"%v\"\t%v", prefixFor(f.Name), f.Name, f.Value, f.Usage)) -} - // Apply takes the flagset and calls Set on the generic flag with the value // provided by the user for parsing by the flag // Ignores parsing errors @@ -178,20 +162,6 @@ func (f *StringSlice) Value() []string { return *f } -type StringSliceFlag struct { - Name string - Value *StringSlice - Usage string - EnvVar string - Required bool -} - -func (f StringSliceFlag) String() string { - firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ") - pref := prefixFor(firstName) - return withHints(f.EnvVar, f.Required, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage)) -} - // Get returns the slice of strings set by this flag func (f *StringSlice) Get() interface{} { return *f @@ -257,20 +227,6 @@ func (f *IntSlice) Value() []int { return *f } -type IntSliceFlag struct { - Name string - Value *IntSlice - Usage string - EnvVar string - Required bool -} - -func (f IntSliceFlag) String() string { - firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ") - pref := prefixFor(firstName) - return withHints(f.EnvVar, f.Required, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage)) -} - // Get returns the slice of ints set by this flag func (f *IntSlice) Get() interface{} { return *f @@ -331,17 +287,6 @@ func (f IntSliceFlag) IsRequired() bool { return f.Required } -type BoolFlag struct { - Name string - Usage string - EnvVar string - Required bool -} - -func (f BoolFlag) String() string { - return withHints(f.EnvVar, f.Required, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage)) -} - // Value returns the slice of ints set by this flag func (f *Int64Slice) Value() []int64 { return *f @@ -394,17 +339,6 @@ func (f BoolFlag) IsRequired() bool { return f.Required } -type BoolTFlag struct { - Name string - Usage string - EnvVar string - Required bool -} - -func (f BoolTFlag) String() string { - return withHints(f.EnvVar, f.Required, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage)) -} - // ApplyWithError populates the flag given the flag set and environment func (f BoolFlag) ApplyWithError(set *flag.FlagSet) error { val := false @@ -468,14 +402,6 @@ func (f BoolTFlag) IsRequired() bool { return f.Required } -type StringFlag struct { - Name string - Value string - Usage string - EnvVar string - Required bool -} - // Apply populates the flag given the flag set and environment // Ignores errors func (f StringFlag) Apply(set *flag.FlagSet) { @@ -536,18 +462,6 @@ func (f StringFlag) IsRequired() bool { return f.Required } -type IntFlag struct { - Name string - Value int - Usage string - EnvVar string - Required bool -} - -func (f IntFlag) String() string { - return withHints(f.EnvVar, f.Required, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)) -} - // ApplyWithError populates the flag given the flag set and environment func (f Int64Flag) ApplyWithError(set *flag.FlagSet) error { if envVal, ok := flagFromFileEnv(f.FilePath, f.EnvVar); ok { @@ -602,18 +516,6 @@ func (f IntFlag) IsRequired() bool { return f.Required } -type DurationFlag struct { - Name string - Value time.Duration - Usage string - EnvVar string - Required bool -} - -func (f DurationFlag) String() string { - return withHints(f.EnvVar, f.Required, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)) -} - // Apply populates the flag given the flag set and environment // Ignores errors func (f Uint64Flag) Apply(set *flag.FlagSet) { @@ -667,24 +569,13 @@ func (f DurationFlag) ApplyWithError(set *flag.FlagSet) error { set.Duration(name, f.Value, f.Usage) }) return nil + } func (f DurationFlag) IsRequired() bool { return f.Required } -type Float64Flag struct { - Name string - Value float64 - Usage string - EnvVar string - Required bool -} - -func (f Float64Flag) String() string { - return withHints(f.EnvVar, f.Required, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage)) -} - // Apply populates the flag given the flag set and environment // Ignores errors func (f Float64Flag) Apply(set *flag.FlagSet) {