From 891ffb017b0946dca5f095853e52f82b57f34d93 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Tue, 26 Jul 2022 16:13:05 +0200 Subject: [PATCH 1/6] Add DestinationPointer for flags generator In this commit I added a DestinationPointer variable that should be set if the `Destination` should be configured as a pointer for a specific flag type. It is expected that Generic type which is an interface will not be a pointer but a struct. Before this change the code compilation was failing with `type *Generic is pointer to interface, not interface`. See https://github.com/urfave/cli/issues/1441 --- cmd/urfave-cli-genflags/generated.gotmpl | 4 + cmd/urfave-cli-genflags/main_test.go | 20 +++- flag-spec.yaml | 27 ++++++ internal/genflags/spec.go | 117 +++++++++++++++++++++++ 4 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 internal/genflags/spec.go diff --git a/cmd/urfave-cli-genflags/generated.gotmpl b/cmd/urfave-cli-genflags/generated.gotmpl index 91312f8..d8c6743 100644 --- a/cmd/urfave-cli-genflags/generated.gotmpl +++ b/cmd/urfave-cli-genflags/generated.gotmpl @@ -17,7 +17,11 @@ type {{.TypeName}} struct { HasBeenSet bool Value {{if .ValuePointer}}*{{end}}{{.GoType}} +<<<<<<< HEAD:cmd/urfave-cli-genflags/generated.gotmpl Destination {{if .NoDestinationPointer}}{{else}}*{{end}}{{.GoType}} +======= + Destination {{if .DestinationPointer}}*{{end}}{{.GoType}} +>>>>>>> Add DestinationPointer for flags generator:internal/genflags/generated.gotmpl Aliases []string EnvVars []string diff --git a/cmd/urfave-cli-genflags/main_test.go b/cmd/urfave-cli-genflags/main_test.go index b5c9fee..61563b1 100644 --- a/cmd/urfave-cli-genflags/main_test.go +++ b/cmd/urfave-cli-genflags/main_test.go @@ -80,8 +80,9 @@ func genFlagType() *main.FlagType { Type: "bool", }, }, - TypeName: "YeOldeBlerfFlag", - ValuePointer: true, + TypeName: "YeOldeBlerfFlag", + ValuePointer: true, + DestinationPointer: true, }, } } @@ -115,6 +116,21 @@ func TestFlagType_ValuePointer(t *testing.T) { } } +func TestFlagType_DestinationPointer(t *testing.T) { + ft := genFlagType() + + if !ft.DestinationPointer() { + t.Errorf("expected DestinationPointer to be true") + return + } + + ft.Config = nil + + if ft.DestinationPointer() { + t.Errorf("expected DestinationPointer to be false") + } +} + func TestFlagType_GenerateFmtStringerInterface(t *testing.T) { ft := genFlagType() diff --git a/flag-spec.yaml b/flag-spec.yaml index 76480ba..9a68cdd 100644 --- a/flag-spec.yaml +++ b/flag-spec.yaml @@ -2,6 +2,7 @@ # ./cmd/urfave-cli-genflags/main.go which uses the # `Spec` type that maps to this file structure. flag_types: +<<<<<<< HEAD bool: struct_fields: - name: Count @@ -13,8 +14,30 @@ flag_types: struct_fields: - name: Action type: "func(*Context, float64) error" +======= + bool: {} + float64: {} + int64: {} + int: {} + time.Duration: {} + uint64: {} + uint: {} + + string: + destination_pointer: true + struct_fields: + - { name: TakesFile, type: bool } + Generic: + struct_fields: + - { name: TakesFile, type: bool } + Path: + destination_pointer: true + struct_fields: + - { name: TakesFile, type: bool } +>>>>>>> Add DestinationPointer for flags generator Float64Slice: value_pointer: true + destination_pointer: true skip_interfaces: - fmt.Stringer struct_fields: @@ -41,6 +64,7 @@ flag_types: type: "func(*Context, int64) error" Int64Slice: value_pointer: true + destination_pointer: true skip_interfaces: - fmt.Stringer struct_fields: @@ -54,6 +78,7 @@ flag_types: type: "func(*Context, uint) error" UintSlice: value_pointer: true + destination_pointer: true skip_interfaces: - fmt.Stringer struct_fields: @@ -80,6 +105,7 @@ flag_types: type: "func(*Context, string) error" StringSlice: value_pointer: true + destination_pointer: true skip_interfaces: - fmt.Stringer struct_fields: @@ -93,6 +119,7 @@ flag_types: type: "func(*Context, time.Duration) error" Timestamp: value_pointer: true + destination_pointer: true struct_fields: - name: Layout type: string diff --git a/internal/genflags/spec.go b/internal/genflags/spec.go new file mode 100644 index 0000000..deff8c9 --- /dev/null +++ b/internal/genflags/spec.go @@ -0,0 +1,117 @@ +package genflags + +import ( + "sort" + "strings" +) + +type Spec struct { + FlagTypes map[string]*FlagTypeConfig `yaml:"flag_types"` + PackageName string `yaml:"package_name"` + TestPackageName string `yaml:"test_package_name"` + UrfaveCLINamespace string `yaml:"urfave_cli_namespace"` + UrfaveCLITestNamespace string `yaml:"urfave_cli_test_namespace"` +} + +func (gfs *Spec) SortedFlagTypes() []*FlagType { + typeNames := []string{} + + for name := range gfs.FlagTypes { + if strings.HasPrefix(name, "[]") { + name = strings.TrimPrefix(name, "[]") + "Slice" + } + + typeNames = append(typeNames, name) + } + + sort.Strings(typeNames) + + ret := make([]*FlagType, len(typeNames)) + + for i, typeName := range typeNames { + ret[i] = &FlagType{ + GoType: typeName, + Config: gfs.FlagTypes[typeName], + } + } + + return ret +} + +type FlagTypeConfig struct { + SkipInterfaces []string `yaml:"skip_interfaces"` + StructFields []*FlagStructField `yaml:"struct_fields"` + TypeName string `yaml:"type_name"` + ValuePointer bool `yaml:"value_pointer"` + DestinationPointer bool `yaml:"destination_pointer"` +} + +type FlagStructField struct { + Name string + Type string +} + +type FlagType struct { + GoType string + Config *FlagTypeConfig +} + +func (ft *FlagType) StructFields() []*FlagStructField { + if ft.Config == nil || ft.Config.StructFields == nil { + return []*FlagStructField{} + } + + return ft.Config.StructFields +} + +func (ft *FlagType) ValuePointer() bool { + if ft.Config == nil { + return false + } + + return ft.Config.ValuePointer +} + +func (ft *FlagType) DestinationPointer() bool { + if ft.Config == nil { + return false + } + + return ft.Config.DestinationPointer +} + +func (ft *FlagType) TypeName() string { + return TypeName(ft.GoType, ft.Config) +} + +func (ft *FlagType) GenerateFmtStringerInterface() bool { + return ft.skipInterfaceNamed("fmt.Stringer") +} + +func (ft *FlagType) GenerateFlagInterface() bool { + return ft.skipInterfaceNamed("Flag") +} + +func (ft *FlagType) GenerateRequiredFlagInterface() bool { + return ft.skipInterfaceNamed("RequiredFlag") +} + +func (ft *FlagType) GenerateVisibleFlagInterface() bool { + return ft.skipInterfaceNamed("VisibleFlag") +} + +func (ft *FlagType) skipInterfaceNamed(name string) bool { + if ft.Config == nil { + return true + } + + lowName := strings.ToLower(name) + + for _, interfaceName := range ft.Config.SkipInterfaces { + if strings.ToLower(interfaceName) == lowName { + return false + } + } + + return true +} From a2541e0fe4d67b0112b2bc2d56d9350edd21bfb1 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Tue, 26 Jul 2022 16:16:02 +0200 Subject: [PATCH 2/6] Set destination in GenericFlag apply function The function was missing destination configuration. --- flag_generic.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flag_generic.go b/flag_generic.go index 5034728..358bd96 100644 --- a/flag_generic.go +++ b/flag_generic.go @@ -62,6 +62,10 @@ func (f *GenericFlag) Apply(set *flag.FlagSet) error { } for _, name := range f.Names() { + if f.Destination != nil { + set.Var(f.Destination, name, f.Usage) + continue + } set.Var(f.Value, name, f.Usage) } From c472192257b94d5418ef7d626c197ac318681e9e Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Tue, 26 Jul 2022 16:16:43 +0200 Subject: [PATCH 3/6] Add unit test for GenericFlag Destination parsing The test checks if Destination provided in GenericFlag is being set as expected. --- flag_test.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/flag_test.go b/flag_test.go index 06f948c..3aafa8b 100644 --- a/flag_test.go +++ b/flag_test.go @@ -2724,6 +2724,53 @@ func TestParseGeneric(t *testing.T) { }).Run([]string{"run", "-s", "10,20"}) } +type genericType struct { + s []string +} + +func (g *genericType) Set(value string) error { + g.s = strings.Split(value, "-") + return nil +} + +func (g *genericType) String() string { + return strings.Join(g.s, "-") +} + +func TestParseDestinationGeneric(t *testing.T) { + expectedString := "abc1-123d" + expectedGeneric := &genericType{[]string{"abc1", "123d"}} + dest := &genericType{} + + _ = (&App{ + Flags: []Flag{ + &GenericFlag{ + Name: "dest", + Destination: dest, + }, + }, + Action: func(ctx *Context) error { + + if !reflect.DeepEqual(dest, expectedGeneric) { + t.Errorf( + "expected destination generic: %+v, actual: %+v", + expectedGeneric, + dest, + ) + } + + if dest.String() != expectedString { + t.Errorf( + "expected destination string: %s, actual: %s", + expectedString, + dest.String(), + ) + } + return nil + }, + }).Run([]string{"run", "--dest", expectedString}) +} + func TestParseGenericFromEnv(t *testing.T) { defer resetEnv(os.Environ()) os.Clearenv() From d724a6314490fb03989d150b462fcc1cc453d29c Mon Sep 17 00:00:00 2001 From: Naveen Gogineni Date: Wed, 5 Oct 2022 22:10:22 -0400 Subject: [PATCH 4/6] After rebase --- cmd/urfave-cli-genflags/generated.gotmpl | 4 ---- flag-spec.yaml | 27 ------------------------ godoc-current.txt | 26 +++++++++++++++++++++++ internal/genflags/spec.go | 12 +++++------ 4 files changed, 32 insertions(+), 37 deletions(-) diff --git a/cmd/urfave-cli-genflags/generated.gotmpl b/cmd/urfave-cli-genflags/generated.gotmpl index d8c6743..91312f8 100644 --- a/cmd/urfave-cli-genflags/generated.gotmpl +++ b/cmd/urfave-cli-genflags/generated.gotmpl @@ -17,11 +17,7 @@ type {{.TypeName}} struct { HasBeenSet bool Value {{if .ValuePointer}}*{{end}}{{.GoType}} -<<<<<<< HEAD:cmd/urfave-cli-genflags/generated.gotmpl Destination {{if .NoDestinationPointer}}{{else}}*{{end}}{{.GoType}} -======= - Destination {{if .DestinationPointer}}*{{end}}{{.GoType}} ->>>>>>> Add DestinationPointer for flags generator:internal/genflags/generated.gotmpl Aliases []string EnvVars []string diff --git a/flag-spec.yaml b/flag-spec.yaml index 9a68cdd..76480ba 100644 --- a/flag-spec.yaml +++ b/flag-spec.yaml @@ -2,7 +2,6 @@ # ./cmd/urfave-cli-genflags/main.go which uses the # `Spec` type that maps to this file structure. flag_types: -<<<<<<< HEAD bool: struct_fields: - name: Count @@ -14,30 +13,8 @@ flag_types: struct_fields: - name: Action type: "func(*Context, float64) error" -======= - bool: {} - float64: {} - int64: {} - int: {} - time.Duration: {} - uint64: {} - uint: {} - - string: - destination_pointer: true - struct_fields: - - { name: TakesFile, type: bool } - Generic: - struct_fields: - - { name: TakesFile, type: bool } - Path: - destination_pointer: true - struct_fields: - - { name: TakesFile, type: bool } ->>>>>>> Add DestinationPointer for flags generator Float64Slice: value_pointer: true - destination_pointer: true skip_interfaces: - fmt.Stringer struct_fields: @@ -64,7 +41,6 @@ flag_types: type: "func(*Context, int64) error" Int64Slice: value_pointer: true - destination_pointer: true skip_interfaces: - fmt.Stringer struct_fields: @@ -78,7 +54,6 @@ flag_types: type: "func(*Context, uint) error" UintSlice: value_pointer: true - destination_pointer: true skip_interfaces: - fmt.Stringer struct_fields: @@ -105,7 +80,6 @@ flag_types: type: "func(*Context, string) error" StringSlice: value_pointer: true - destination_pointer: true skip_interfaces: - fmt.Stringer struct_fields: @@ -119,7 +93,6 @@ flag_types: type: "func(*Context, time.Duration) error" Timestamp: value_pointer: true - destination_pointer: true struct_fields: - name: Layout type: string diff --git a/godoc-current.txt b/godoc-current.txt index efbac4d..6b3c739 100644 --- a/godoc-current.txt +++ b/godoc-current.txt @@ -753,6 +753,14 @@ type DocGenerationFlag interface { DocGenerationFlag is an interface that allows documentation generation for the flag +type DocGenerationSliceFlag interface { + DocGenerationFlag + + // IsSliceFlag returns true for flags that can be given multiple times. + IsSliceFlag() bool +} + DocGenerationSliceFlag extends DocGenerationFlag for slice-based flags. + type DurationFlag struct { Name string @@ -1071,6 +1079,9 @@ func (f *Float64SliceFlag) IsRequired() bool func (f *Float64SliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *Float64SliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *Float64SliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -1306,6 +1317,9 @@ func (f *Int64SliceFlag) IsRequired() bool func (f *Int64SliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *Int64SliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *Int64SliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -1471,6 +1485,9 @@ func (f *IntSliceFlag) IsRequired() bool func (f *IntSliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *IntSliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *IntSliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -1810,6 +1827,9 @@ func (f *StringSliceFlag) IsRequired() bool func (f *StringSliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *StringSliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *StringSliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -2071,6 +2091,9 @@ func (f *Uint64SliceFlag) IsRequired() bool func (f *Uint64SliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *Uint64SliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *Uint64SliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -2227,6 +2250,9 @@ func (f *UintSliceFlag) IsRequired() bool func (f *UintSliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *UintSliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *UintSliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false diff --git a/internal/genflags/spec.go b/internal/genflags/spec.go index deff8c9..f30eebc 100644 --- a/internal/genflags/spec.go +++ b/internal/genflags/spec.go @@ -39,11 +39,11 @@ func (gfs *Spec) SortedFlagTypes() []*FlagType { } type FlagTypeConfig struct { - SkipInterfaces []string `yaml:"skip_interfaces"` - StructFields []*FlagStructField `yaml:"struct_fields"` - TypeName string `yaml:"type_name"` - ValuePointer bool `yaml:"value_pointer"` - DestinationPointer bool `yaml:"destination_pointer"` + SkipInterfaces []string `yaml:"skip_interfaces"` + StructFields []*FlagStructField `yaml:"struct_fields"` + TypeName string `yaml:"type_name"` + ValuePointer bool `yaml:"value_pointer"` + NoDestinationPointer bool `yaml:"no_destination_pointer"` } type FlagStructField struct { @@ -77,7 +77,7 @@ func (ft *FlagType) DestinationPointer() bool { return false } - return ft.Config.DestinationPointer + return ft.Config.NoDestinationPointer } func (ft *FlagType) TypeName() string { From a9c758e55fd045ca0535ce33e4df03703fbc9266 Mon Sep 17 00:00:00 2001 From: Naveen Gogineni Date: Wed, 5 Oct 2022 22:15:43 -0400 Subject: [PATCH 5/6] Fix compile --- internal/genflags/spec.go | 117 -------------------------------------- testdata/godoc-v2.x.txt | 26 +++++++++ 2 files changed, 26 insertions(+), 117 deletions(-) delete mode 100644 internal/genflags/spec.go diff --git a/internal/genflags/spec.go b/internal/genflags/spec.go deleted file mode 100644 index f30eebc..0000000 --- a/internal/genflags/spec.go +++ /dev/null @@ -1,117 +0,0 @@ -package genflags - -import ( - "sort" - "strings" -) - -type Spec struct { - FlagTypes map[string]*FlagTypeConfig `yaml:"flag_types"` - PackageName string `yaml:"package_name"` - TestPackageName string `yaml:"test_package_name"` - UrfaveCLINamespace string `yaml:"urfave_cli_namespace"` - UrfaveCLITestNamespace string `yaml:"urfave_cli_test_namespace"` -} - -func (gfs *Spec) SortedFlagTypes() []*FlagType { - typeNames := []string{} - - for name := range gfs.FlagTypes { - if strings.HasPrefix(name, "[]") { - name = strings.TrimPrefix(name, "[]") + "Slice" - } - - typeNames = append(typeNames, name) - } - - sort.Strings(typeNames) - - ret := make([]*FlagType, len(typeNames)) - - for i, typeName := range typeNames { - ret[i] = &FlagType{ - GoType: typeName, - Config: gfs.FlagTypes[typeName], - } - } - - return ret -} - -type FlagTypeConfig struct { - SkipInterfaces []string `yaml:"skip_interfaces"` - StructFields []*FlagStructField `yaml:"struct_fields"` - TypeName string `yaml:"type_name"` - ValuePointer bool `yaml:"value_pointer"` - NoDestinationPointer bool `yaml:"no_destination_pointer"` -} - -type FlagStructField struct { - Name string - Type string -} - -type FlagType struct { - GoType string - Config *FlagTypeConfig -} - -func (ft *FlagType) StructFields() []*FlagStructField { - if ft.Config == nil || ft.Config.StructFields == nil { - return []*FlagStructField{} - } - - return ft.Config.StructFields -} - -func (ft *FlagType) ValuePointer() bool { - if ft.Config == nil { - return false - } - - return ft.Config.ValuePointer -} - -func (ft *FlagType) DestinationPointer() bool { - if ft.Config == nil { - return false - } - - return ft.Config.NoDestinationPointer -} - -func (ft *FlagType) TypeName() string { - return TypeName(ft.GoType, ft.Config) -} - -func (ft *FlagType) GenerateFmtStringerInterface() bool { - return ft.skipInterfaceNamed("fmt.Stringer") -} - -func (ft *FlagType) GenerateFlagInterface() bool { - return ft.skipInterfaceNamed("Flag") -} - -func (ft *FlagType) GenerateRequiredFlagInterface() bool { - return ft.skipInterfaceNamed("RequiredFlag") -} - -func (ft *FlagType) GenerateVisibleFlagInterface() bool { - return ft.skipInterfaceNamed("VisibleFlag") -} - -func (ft *FlagType) skipInterfaceNamed(name string) bool { - if ft.Config == nil { - return true - } - - lowName := strings.ToLower(name) - - for _, interfaceName := range ft.Config.SkipInterfaces { - if strings.ToLower(interfaceName) == lowName { - return false - } - } - - return true -} diff --git a/testdata/godoc-v2.x.txt b/testdata/godoc-v2.x.txt index efbac4d..6b3c739 100644 --- a/testdata/godoc-v2.x.txt +++ b/testdata/godoc-v2.x.txt @@ -753,6 +753,14 @@ type DocGenerationFlag interface { DocGenerationFlag is an interface that allows documentation generation for the flag +type DocGenerationSliceFlag interface { + DocGenerationFlag + + // IsSliceFlag returns true for flags that can be given multiple times. + IsSliceFlag() bool +} + DocGenerationSliceFlag extends DocGenerationFlag for slice-based flags. + type DurationFlag struct { Name string @@ -1071,6 +1079,9 @@ func (f *Float64SliceFlag) IsRequired() bool func (f *Float64SliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *Float64SliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *Float64SliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -1306,6 +1317,9 @@ func (f *Int64SliceFlag) IsRequired() bool func (f *Int64SliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *Int64SliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *Int64SliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -1471,6 +1485,9 @@ func (f *IntSliceFlag) IsRequired() bool func (f *IntSliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *IntSliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *IntSliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -1810,6 +1827,9 @@ func (f *StringSliceFlag) IsRequired() bool func (f *StringSliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *StringSliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *StringSliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -2071,6 +2091,9 @@ func (f *Uint64SliceFlag) IsRequired() bool func (f *Uint64SliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *Uint64SliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *Uint64SliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false @@ -2227,6 +2250,9 @@ func (f *UintSliceFlag) IsRequired() bool func (f *UintSliceFlag) IsSet() bool IsSet returns whether or not the flag has been set through env or file +func (f *UintSliceFlag) IsSliceFlag() bool + IsSliceFlag implements DocGenerationSliceFlag. + func (f *UintSliceFlag) IsVisible() bool IsVisible returns true if the flag is not hidden, otherwise false From 67f293a1e5388244ce0d7446320d7e54e4e6f839 Mon Sep 17 00:00:00 2001 From: Naveen Gogineni Date: Wed, 5 Oct 2022 22:18:45 -0400 Subject: [PATCH 6/6] Revert main_test --- cmd/urfave-cli-genflags/main_test.go | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/cmd/urfave-cli-genflags/main_test.go b/cmd/urfave-cli-genflags/main_test.go index 61563b1..b5c9fee 100644 --- a/cmd/urfave-cli-genflags/main_test.go +++ b/cmd/urfave-cli-genflags/main_test.go @@ -80,9 +80,8 @@ func genFlagType() *main.FlagType { Type: "bool", }, }, - TypeName: "YeOldeBlerfFlag", - ValuePointer: true, - DestinationPointer: true, + TypeName: "YeOldeBlerfFlag", + ValuePointer: true, }, } } @@ -116,21 +115,6 @@ func TestFlagType_ValuePointer(t *testing.T) { } } -func TestFlagType_DestinationPointer(t *testing.T) { - ft := genFlagType() - - if !ft.DestinationPointer() { - t.Errorf("expected DestinationPointer to be true") - return - } - - ft.Config = nil - - if ft.DestinationPointer() { - t.Errorf("expected DestinationPointer to be false") - } -} - func TestFlagType_GenerateFmtStringerInterface(t *testing.T) { ft := genFlagType()