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

@ -16,6 +16,7 @@ type BoolFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Destination *bool
@ -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
@ -87,6 +93,7 @@ type BoolTFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Destination *bool
@ -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
@ -158,6 +170,7 @@ type DurationFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value time.Duration
@ -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
@ -230,6 +248,7 @@ type Float64Flag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value float64
@ -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
@ -302,6 +326,7 @@ type GenericFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value Generic
@ -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
@ -376,6 +406,7 @@ type Int64Flag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value int64
@ -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
@ -448,6 +484,7 @@ type IntFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value int
@ -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
@ -520,6 +562,7 @@ type IntSliceFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value *IntSlice
@ -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
@ -594,6 +642,7 @@ type Int64SliceFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value *Int64Slice
@ -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
@ -668,6 +722,7 @@ type StringFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value string
@ -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
@ -740,6 +800,7 @@ type StringSliceFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value *StringSlice
@ -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
@ -814,6 +880,7 @@ type Uint64Flag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value uint64
@ -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
@ -886,6 +958,7 @@ type UintFlag struct {
EnvVar string
FilePath string
Required bool
RequiredFlagsErr bool
Hidden bool
TakesFile bool
Value uint
@ -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