manually add FlagsErrRequired field and function to generated flags

main
Aaron Berns 5 years ago
parent 95f45c1e60
commit a064d9082c

@ -88,7 +88,7 @@ type RequiredFlag interface {
type RequiredFlagsErr interface {
Flag
IsRequired() bool
FlagsErrRequired() bool
}
// DocGenerationFlag is an interface that allows documentation generation for the flag

@ -11,14 +11,15 @@ import (
// BoolFlag is a flag with type bool
type BoolFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Destination *bool
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Destination *bool
}
// String returns a readable representation of this value
@ -37,6 +38,11 @@ func (f BoolFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f BoolFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f BoolFlag) TakesValue() bool {
return false
@ -82,14 +88,15 @@ func lookupBool(name string, set *flag.FlagSet) bool {
// BoolTFlag is a flag with type bool that is true by default
type BoolTFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Destination *bool
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Destination *bool
}
// String returns a readable representation of this value
@ -108,6 +115,11 @@ func (f BoolTFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f BoolTFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f BoolTFlag) TakesValue() bool {
return false
@ -153,15 +165,16 @@ func lookupBoolT(name string, set *flag.FlagSet) bool {
// DurationFlag is a flag with type time.Duration (see https://golang.org/pkg/time/#ParseDuration)
type DurationFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value time.Duration
Destination *time.Duration
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value time.Duration
Destination *time.Duration
}
// String returns a readable representation of this value
@ -180,6 +193,11 @@ func (f DurationFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f DurationFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f DurationFlag) TakesValue() bool {
return true
@ -225,15 +243,16 @@ func lookupDuration(name string, set *flag.FlagSet) time.Duration {
// Float64Flag is a flag with type float64
type Float64Flag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value float64
Destination *float64
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value float64
Destination *float64
}
// String returns a readable representation of this value
@ -252,6 +271,11 @@ func (f Float64Flag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f Float64Flag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f Float64Flag) TakesValue() bool {
return true
@ -297,14 +321,15 @@ func lookupFloat64(name string, set *flag.FlagSet) float64 {
// GenericFlag is a flag with type Generic
type GenericFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value Generic
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value Generic
}
// String returns a readable representation of this value
@ -323,6 +348,11 @@ func (f GenericFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f GenericFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f GenericFlag) TakesValue() bool {
return true
@ -371,15 +401,16 @@ func lookupGeneric(name string, set *flag.FlagSet) interface{} {
// Int64Flag is a flag with type int64
type Int64Flag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value int64
Destination *int64
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value int64
Destination *int64
}
// String returns a readable representation of this value
@ -398,6 +429,11 @@ func (f Int64Flag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f Int64Flag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f Int64Flag) TakesValue() bool {
return true
@ -443,15 +479,16 @@ func lookupInt64(name string, set *flag.FlagSet) int64 {
// IntFlag is a flag with type int
type IntFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value int
Destination *int
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value int
Destination *int
}
// String returns a readable representation of this value
@ -470,6 +507,11 @@ func (f IntFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f IntFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f IntFlag) TakesValue() bool {
return true
@ -515,14 +557,15 @@ func lookupInt(name string, set *flag.FlagSet) int {
// IntSliceFlag is a flag with type *IntSlice
type IntSliceFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value *IntSlice
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value *IntSlice
}
// String returns a readable representation of this value
@ -541,6 +584,11 @@ func (f IntSliceFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f IntSliceFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f IntSliceFlag) TakesValue() bool {
return true
@ -589,14 +637,15 @@ func lookupIntSlice(name string, set *flag.FlagSet) []int {
// Int64SliceFlag is a flag with type *Int64Slice
type Int64SliceFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value *Int64Slice
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value *Int64Slice
}
// String returns a readable representation of this value
@ -615,6 +664,11 @@ func (f Int64SliceFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f Int64SliceFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f Int64SliceFlag) TakesValue() bool {
return true
@ -663,15 +717,16 @@ func lookupInt64Slice(name string, set *flag.FlagSet) []int64 {
// StringFlag is a flag with type string
type StringFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value string
Destination *string
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value string
Destination *string
}
// String returns a readable representation of this value
@ -690,6 +745,11 @@ func (f StringFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f StringFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f StringFlag) TakesValue() bool {
return true
@ -735,14 +795,15 @@ func lookupString(name string, set *flag.FlagSet) string {
// StringSliceFlag is a flag with type *StringSlice
type StringSliceFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value *StringSlice
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value *StringSlice
}
// String returns a readable representation of this value
@ -761,6 +822,11 @@ func (f StringSliceFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f StringSliceFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f StringSliceFlag) TakesValue() bool {
return true
@ -809,15 +875,16 @@ func lookupStringSlice(name string, set *flag.FlagSet) []string {
// Uint64Flag is a flag with type uint64
type Uint64Flag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value uint64
Destination *uint64
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value uint64
Destination *uint64
}
// String returns a readable representation of this value
@ -836,6 +903,11 @@ func (f Uint64Flag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f Uint64Flag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f Uint64Flag) TakesValue() bool {
return true
@ -881,15 +953,16 @@ func lookupUint64(name string, set *flag.FlagSet) uint64 {
// UintFlag is a flag with type uint
type UintFlag struct {
Name string
Usage string
EnvVar string
FilePath string
Required bool
Hidden bool
TakesFile bool
Value uint
Destination *uint
Name string
Usage string
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value uint
Destination *uint
}
// String returns a readable representation of this value
@ -908,6 +981,11 @@ func (f UintFlag) IsRequired() bool {
return f.Required
}
// FlagsErrRequired returns whether or not the flag is required
func (f UintFlag) FlagsErrRequired() bool {
return f.RequiredFlagsErr
}
// TakesValue returns true of the flag takes a value, otherwise false
func (f UintFlag) TakesValue() bool {
return true
@ -950,4 +1028,3 @@ func lookupUint(name string, set *flag.FlagSet) uint {
}
return 0
}

Loading…
Cancel
Save