Fix: dont generate pointer for dest for Generic flag

This commit is contained in:
Naveen Gogineni
2022-09-10 18:03:25 -04:00
committed by Dan Buch
parent 0658d61a0e
commit e13c16bb10
4 changed files with 67 additions and 51 deletions

View File

@@ -17,7 +17,7 @@ type {{.TypeName}} struct {
HasBeenSet bool
Value {{if .ValuePointer}}*{{end}}{{.GoType}}
Destination *{{.GoType}}
Destination {{if .NoDestinationPointer}}{{else}}*{{end}}{{.GoType}}
Aliases []string
EnvVars []string

View File

@@ -223,10 +223,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"`
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 {
@@ -256,6 +257,14 @@ func (ft *FlagType) ValuePointer() bool {
return ft.Config.ValuePointer
}
func (ft *FlagType) NoDestinationPointer() bool {
if ft.Config == nil {
return false
}
return ft.Config.NoDestinationPointer
}
func (ft *FlagType) TypeName() string {
return TypeName(ft.GoType, ft.Config)
}