Dan Buch
2ca91434a8
to alleviate problems caused by the circular dependency of using the same code as a library that is potentially being generated to adhere to a different API.
96 lines
2.2 KiB
Go Template
96 lines
2.2 KiB
Go Template
// WARNING: this file is generated. DO NOT EDIT
|
|
|
|
package {{.PackageName}}
|
|
|
|
{{range .SortedFlagTypes}}
|
|
// {{.TypeName}} is a flag with type {{if .ValuePointer}}*{{end}}{{.GoType}}
|
|
type {{.TypeName}} struct {
|
|
Name string
|
|
|
|
Category string
|
|
DefaultText string
|
|
FilePath string
|
|
Usage string
|
|
|
|
Required bool
|
|
Hidden bool
|
|
HasBeenSet bool
|
|
|
|
Value {{if .ValuePointer}}*{{end}}{{.GoType}}
|
|
Destination *{{.GoType}}
|
|
|
|
Aliases []string
|
|
EnvVars []string
|
|
|
|
{{range .StructFields}}
|
|
{{.Name}} {{.Type}}
|
|
{{end}}
|
|
}
|
|
|
|
{{if .GenerateFmtStringerInterface}}
|
|
// String returns a readable representation of this value (for usage defaults)
|
|
func (f *{{.TypeName}}) String() string {
|
|
return {{$.UrfaveCLINamespace}}FlagStringer(f)
|
|
}
|
|
{{end}}{{/* /if .GenerateFmtStringerInterface */}}
|
|
|
|
{{if .GenerateFlagInterface}}
|
|
// IsSet returns whether or not the flag has been set through env or file
|
|
func (f *{{.TypeName}}) IsSet() bool {
|
|
return f.HasBeenSet
|
|
}
|
|
|
|
// Names returns the names of the flag
|
|
func (f *{{.TypeName}}) Names() []string {
|
|
return {{$.UrfaveCLINamespace}}FlagNames(f.Name, f.Aliases)
|
|
}
|
|
|
|
// IsRequired returns whether or not the flag is required
|
|
func (f *{{.TypeName}}) IsRequired() bool {
|
|
return f.Required
|
|
}
|
|
|
|
// IsVisible returns true if the flag is not hidden, otherwise false
|
|
func (f *{{.TypeName}}) IsVisible() bool {
|
|
return !f.Hidden
|
|
}
|
|
|
|
// GetCategory returns the category of the flag
|
|
func (f *{{.TypeName}}) GetCategory() string {
|
|
return f.Category
|
|
}
|
|
|
|
// GetUsage returns the usage string for the flag
|
|
func (f *{{.TypeName}}) GetUsage() string {
|
|
return f.Usage
|
|
}
|
|
|
|
// GetEnvVars returns the env vars for this flag
|
|
func (f *{{.TypeName}}) GetEnvVars() []string {
|
|
return f.EnvVars
|
|
}
|
|
|
|
// TakesValue returns true if the flag takes a value, otherwise false
|
|
func (f *{{.TypeName}}) TakesValue() bool {
|
|
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}}{{/* /range .SortedFlagTypes */}}
|
|
|
|
// vim{{/* 👻 */}}:ro
|
|
{{/*
|
|
vim:filetype=gotexttmpl
|
|
*/}}
|