Revert changes
This commit is contained in:
parent
1a31a6e2fc
commit
cf41aab451
@ -2386,6 +2386,10 @@ func (c *customBoolFlag) GetEnvVars() []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *customBoolFlag) GetDefaultText() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func TestCustomFlagsUnused(t *testing.T) {
|
func TestCustomFlagsUnused(t *testing.T) {
|
||||||
app := &App{
|
app := &App{
|
||||||
Flags: []Flag{&customBoolFlag{"custom"}},
|
Flags: []Flag{&customBoolFlag{"custom"}},
|
||||||
|
@ -75,6 +75,16 @@ func (f *{{.TypeName}}) TakesValue() bool {
|
|||||||
return "{{.TypeName }}" != "BoolFlag"
|
return "{{.TypeName }}" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{if .GenerateDefaultText}}
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *{{.TypeName}}) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{end}}{{/* /if .GenerateFlagInterface */}}
|
{{end}}{{/* /if .GenerateFlagInterface */}}
|
||||||
|
|
||||||
{{end}}{{/* /range .SortedFlagTypes */}}
|
{{end}}{{/* /range .SortedFlagTypes */}}
|
||||||
|
@ -12,13 +12,13 @@ func Test{{.TypeName}}_SatisfiesFlagInterface(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test{{.TypeName}}_SatisfiesRequiredFlagInterface(t *testing.T) {
|
func Test{{.TypeName}}_SatisfiesRequiredFlagInterface(t *testing.T) {
|
||||||
var f {{$.UrfaveCLITestNamespace}}RequiredFlag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{}
|
var f {{$.UrfaveCLITestNamespace}}Flag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{}
|
||||||
|
|
||||||
_ = f.IsRequired()
|
_ = f.IsRequired()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test{{.TypeName}}_SatisfiesVisibleFlagInterface(t *testing.T) {
|
func Test{{.TypeName}}_SatisfiesVisibleFlagInterface(t *testing.T) {
|
||||||
var f {{$.UrfaveCLITestNamespace}}VisibleFlag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{}
|
var f {{$.UrfaveCLITestNamespace}}Flag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{}
|
||||||
|
|
||||||
_ = f.IsVisible()
|
_ = f.IsVisible()
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,6 @@ func (f *DurationFlag) GetValue() string {
|
|||||||
return f.Value.String()
|
return f.Value.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *DurationFlag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply populates the flag given the flag set and environment
|
// Apply populates the flag given the flag set and environment
|
||||||
func (f *DurationFlag) Apply(set *flag.FlagSet) error {
|
func (f *DurationFlag) Apply(set *flag.FlagSet) error {
|
||||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||||
|
@ -12,14 +12,6 @@ func (f *Float64Flag) GetValue() string {
|
|||||||
return fmt.Sprintf("%v", f.Value)
|
return fmt.Sprintf("%v", f.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *Float64Flag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply populates the flag given the flag set and environment
|
// Apply populates the flag given the flag set and environment
|
||||||
func (f *Float64Flag) Apply(set *flag.FlagSet) error {
|
func (f *Float64Flag) Apply(set *flag.FlagSet) error {
|
||||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||||
|
@ -95,14 +95,6 @@ func (f *Float64SliceFlag) GetValue() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *Float64SliceFlag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply populates the flag given the flag set and environment
|
// Apply populates the flag given the flag set and environment
|
||||||
func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error {
|
func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error {
|
||||||
// apply any default
|
// apply any default
|
||||||
|
@ -20,14 +20,6 @@ func (f *GenericFlag) GetValue() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *GenericFlag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply takes the flagset and calls Set on the generic flag with the value
|
// Apply takes the flagset and calls Set on the generic flag with the value
|
||||||
// provided by the user for parsing by the flag
|
// provided by the user for parsing by the flag
|
||||||
func (f *GenericFlag) Apply(set *flag.FlagSet) error {
|
func (f *GenericFlag) Apply(set *flag.FlagSet) error {
|
||||||
|
@ -12,14 +12,6 @@ func (f *IntFlag) GetValue() string {
|
|||||||
return fmt.Sprintf("%d", f.Value)
|
return fmt.Sprintf("%d", f.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *IntFlag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply populates the flag given the flag set and environment
|
// Apply populates the flag given the flag set and environment
|
||||||
func (f *IntFlag) Apply(set *flag.FlagSet) error {
|
func (f *IntFlag) Apply(set *flag.FlagSet) error {
|
||||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||||
|
@ -12,14 +12,6 @@ func (f *Int64Flag) GetValue() string {
|
|||||||
return fmt.Sprintf("%d", f.Value)
|
return fmt.Sprintf("%d", f.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *Int64Flag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply populates the flag given the flag set and environment
|
// Apply populates the flag given the flag set and environment
|
||||||
func (f *Int64Flag) Apply(set *flag.FlagSet) error {
|
func (f *Int64Flag) Apply(set *flag.FlagSet) error {
|
||||||
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
|
||||||
|
@ -96,14 +96,6 @@ func (f *Int64SliceFlag) GetValue() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *Int64SliceFlag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply populates the flag given the flag set and environment
|
// Apply populates the flag given the flag set and environment
|
||||||
func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error {
|
func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error {
|
||||||
// apply any default
|
// apply any default
|
||||||
|
@ -107,14 +107,6 @@ func (f *IntSliceFlag) GetValue() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *IntSliceFlag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply populates the flag given the flag set and environment
|
// Apply populates the flag given the flag set and environment
|
||||||
func (f *IntSliceFlag) Apply(set *flag.FlagSet) error {
|
func (f *IntSliceFlag) Apply(set *flag.FlagSet) error {
|
||||||
// apply any default
|
// apply any default
|
||||||
|
@ -86,14 +86,6 @@ func (f *StringSliceFlag) GetValue() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *StringSliceFlag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply populates the flag given the flag set and environment
|
// Apply populates the flag given the flag set and environment
|
||||||
func (f *StringSliceFlag) Apply(set *flag.FlagSet) error {
|
func (f *StringSliceFlag) Apply(set *flag.FlagSet) error {
|
||||||
// apply any default
|
// apply any default
|
||||||
|
@ -81,14 +81,6 @@ func (f *TimestampFlag) GetValue() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *TimestampFlag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply populates the flag given the flag set and environment
|
// Apply populates the flag given the flag set and environment
|
||||||
func (f *TimestampFlag) Apply(set *flag.FlagSet) error {
|
func (f *TimestampFlag) Apply(set *flag.FlagSet) error {
|
||||||
if f.Layout == "" {
|
if f.Layout == "" {
|
||||||
|
@ -37,14 +37,6 @@ func (f *UintFlag) GetValue() string {
|
|||||||
return fmt.Sprintf("%d", f.Value)
|
return fmt.Sprintf("%d", f.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *UintFlag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns the flag’s value in the given Context.
|
// Get returns the flag’s value in the given Context.
|
||||||
func (f *UintFlag) Get(ctx *Context) uint {
|
func (f *UintFlag) Get(ctx *Context) uint {
|
||||||
return ctx.Uint(f.Name)
|
return ctx.Uint(f.Name)
|
||||||
|
@ -37,14 +37,6 @@ func (f *Uint64Flag) GetValue() string {
|
|||||||
return fmt.Sprintf("%d", f.Value)
|
return fmt.Sprintf("%d", f.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultText returns the default text for this flag
|
|
||||||
func (f *Uint64Flag) GetDefaultText() string {
|
|
||||||
if f.DefaultText != "" {
|
|
||||||
return f.DefaultText
|
|
||||||
}
|
|
||||||
return f.GetValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns the flag’s value in the given Context.
|
// Get returns the flag’s value in the given Context.
|
||||||
func (f *Uint64Flag) Get(ctx *Context) uint64 {
|
func (f *Uint64Flag) Get(ctx *Context) uint64 {
|
||||||
return ctx.Uint64(f.Name)
|
return ctx.Uint64(f.Name)
|
||||||
|
@ -66,6 +66,14 @@ func (f *Float64SliceFlag) TakesValue() bool {
|
|||||||
return "Float64SliceFlag" != "BoolFlag"
|
return "Float64SliceFlag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *Float64SliceFlag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// GenericFlag is a flag with type Generic
|
// GenericFlag is a flag with type Generic
|
||||||
type GenericFlag struct {
|
type GenericFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -135,6 +143,14 @@ func (f *GenericFlag) TakesValue() bool {
|
|||||||
return "GenericFlag" != "BoolFlag"
|
return "GenericFlag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *GenericFlag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// Int64SliceFlag is a flag with type *Int64Slice
|
// Int64SliceFlag is a flag with type *Int64Slice
|
||||||
type Int64SliceFlag struct {
|
type Int64SliceFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -197,6 +213,14 @@ func (f *Int64SliceFlag) TakesValue() bool {
|
|||||||
return "Int64SliceFlag" != "BoolFlag"
|
return "Int64SliceFlag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *Int64SliceFlag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// IntSliceFlag is a flag with type *IntSlice
|
// IntSliceFlag is a flag with type *IntSlice
|
||||||
type IntSliceFlag struct {
|
type IntSliceFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -259,6 +283,14 @@ func (f *IntSliceFlag) TakesValue() bool {
|
|||||||
return "IntSliceFlag" != "BoolFlag"
|
return "IntSliceFlag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *IntSliceFlag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// PathFlag is a flag with type Path
|
// PathFlag is a flag with type Path
|
||||||
type PathFlag struct {
|
type PathFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -392,6 +424,14 @@ func (f *StringSliceFlag) TakesValue() bool {
|
|||||||
return "StringSliceFlag" != "BoolFlag"
|
return "StringSliceFlag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *StringSliceFlag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// TimestampFlag is a flag with type *Timestamp
|
// TimestampFlag is a flag with type *Timestamp
|
||||||
type TimestampFlag struct {
|
type TimestampFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -463,6 +503,14 @@ func (f *TimestampFlag) TakesValue() bool {
|
|||||||
return "TimestampFlag" != "BoolFlag"
|
return "TimestampFlag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *TimestampFlag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// Uint64SliceFlag is a flag with type *Uint64Slice
|
// Uint64SliceFlag is a flag with type *Uint64Slice
|
||||||
type Uint64SliceFlag struct {
|
type Uint64SliceFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -683,6 +731,14 @@ func (f *Float64Flag) TakesValue() bool {
|
|||||||
return "Float64Flag" != "BoolFlag"
|
return "Float64Flag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *Float64Flag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// IntFlag is a flag with type int
|
// IntFlag is a flag with type int
|
||||||
type IntFlag struct {
|
type IntFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -752,6 +808,14 @@ func (f *IntFlag) TakesValue() bool {
|
|||||||
return "IntFlag" != "BoolFlag"
|
return "IntFlag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *IntFlag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// Int64Flag is a flag with type int64
|
// Int64Flag is a flag with type int64
|
||||||
type Int64Flag struct {
|
type Int64Flag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -821,6 +885,14 @@ func (f *Int64Flag) TakesValue() bool {
|
|||||||
return "Int64Flag" != "BoolFlag"
|
return "Int64Flag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *Int64Flag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// StringFlag is a flag with type string
|
// StringFlag is a flag with type string
|
||||||
type StringFlag struct {
|
type StringFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -957,6 +1029,14 @@ func (f *DurationFlag) TakesValue() bool {
|
|||||||
return "DurationFlag" != "BoolFlag"
|
return "DurationFlag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *DurationFlag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// UintFlag is a flag with type uint
|
// UintFlag is a flag with type uint
|
||||||
type UintFlag struct {
|
type UintFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -1026,6 +1106,14 @@ func (f *UintFlag) TakesValue() bool {
|
|||||||
return "UintFlag" != "BoolFlag"
|
return "UintFlag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *UintFlag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// Uint64Flag is a flag with type uint64
|
// Uint64Flag is a flag with type uint64
|
||||||
type Uint64Flag struct {
|
type Uint64Flag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -1095,4 +1183,12 @@ func (f *Uint64Flag) TakesValue() bool {
|
|||||||
return "Uint64Flag" != "BoolFlag"
|
return "Uint64Flag" != "BoolFlag"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDefaultText returns the default text for this flag
|
||||||
|
func (f *Uint64Flag) GetDefaultText() string {
|
||||||
|
if f.DefaultText != "" {
|
||||||
|
return f.DefaultText
|
||||||
|
}
|
||||||
|
return f.GetValue()
|
||||||
|
}
|
||||||
|
|
||||||
// vim:ro
|
// vim:ro
|
||||||
|
Loading…
x
Reference in New Issue
Block a user