From 85ff0c550a4124bfa742cc97b90034b638ca0ece Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Thu, 13 Oct 2022 08:15:14 -0400 Subject: [PATCH] Un-regress from v3 porting losses --- .github/workflows/cli.yml | 5 +- Makefile | 2 +- cmd/urfave-cli-genflags/generated_test.gotmpl | 4 +- flag_duration.go | 8 ++ flag_float64.go | 8 ++ flag_float64_slice.go | 8 ++ flag_generic.go | 8 ++ flag_int.go | 8 ++ flag_int64.go | 8 ++ flag_int64_slice.go | 8 ++ flag_int_slice.go | 8 ++ flag_string_slice.go | 8 ++ flag_test.go | 2 +- flag_timestamp.go | 8 ++ flag_uint.go | 8 ++ flag_uint64.go | 8 ++ flag_uint64_slice.go | 20 --- flag_uint_slice.go | 20 --- godoc-current.txt | 91 +++++++----- zz_generated.flags.go | 136 ++++++------------ zz_generated.flags_test.go | 24 ++++ 21 files changed, 220 insertions(+), 180 deletions(-) diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index 39298b8..5c8db7a 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -46,8 +46,11 @@ jobs: - if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest' run: make generate - run: make diffcheck - - if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest' + # TODO: switch once v3 is released {{ + # - if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest' + - if: 'false' run: make v2diff + # }} - if: success() && matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@v3 with: diff --git a/Makefile b/Makefile index f0d4190..a167052 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ GO_RUN_BUILD := go run internal/build/build.go .PHONY: all -all: generate vet test check-binary-size gfmrun yamlfmt v2diff +all: generate vet test check-binary-size gfmrun yamlfmt # NOTE: this is a special catch-all rule to run any of the commands # defined in internal/build/build.go with optional arguments passed diff --git a/cmd/urfave-cli-genflags/generated_test.gotmpl b/cmd/urfave-cli-genflags/generated_test.gotmpl index c91f562..83229b0 100644 --- a/cmd/urfave-cli-genflags/generated_test.gotmpl +++ b/cmd/urfave-cli-genflags/generated_test.gotmpl @@ -12,13 +12,13 @@ func Test{{.TypeName}}_SatisfiesFlagInterface(t *testing.T) { } func Test{{.TypeName}}_SatisfiesRequiredFlagInterface(t *testing.T) { - var f {{$.UrfaveCLITestNamespace}}Flag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{} + var f {{$.UrfaveCLITestNamespace}}RequiredFlag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{} _ = f.IsRequired() } func Test{{.TypeName}}_SatisfiesVisibleFlagInterface(t *testing.T) { - var f {{$.UrfaveCLITestNamespace}}Flag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{} + var f {{$.UrfaveCLITestNamespace}}VisibleFlag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{} _ = f.IsVisible() } diff --git a/flag_duration.go b/flag_duration.go index b6adce3..06391f3 100644 --- a/flag_duration.go +++ b/flag_duration.go @@ -12,6 +12,14 @@ func (f *DurationFlag) GetValue() 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 func (f *DurationFlag) Apply(set *flag.FlagSet) error { if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { diff --git a/flag_float64.go b/flag_float64.go index 3e21a01..d522ac0 100644 --- a/flag_float64.go +++ b/flag_float64.go @@ -12,6 +12,14 @@ func (f *Float64Flag) GetValue() string { 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 func (f *Float64Flag) Apply(set *flag.FlagSet) error { if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { diff --git a/flag_float64_slice.go b/flag_float64_slice.go index 3f8aef1..d060432 100644 --- a/flag_float64_slice.go +++ b/flag_float64_slice.go @@ -98,6 +98,14 @@ func (f *Float64SliceFlag) GetValue() string { return strings.Join(defaultVals, ", ") } +// GetDefaultText returns the default text for this flag +func (f *Float64SliceFlag) GetDefaultText() string { + if f.DefaultText != "" { + return f.DefaultText + } + return f.GetValue() +} + // IsSliceFlag implements DocGenerationSliceFlag. func (f *Float64SliceFlag) IsSliceFlag() bool { return true diff --git a/flag_generic.go b/flag_generic.go index daed474..d0f6527 100644 --- a/flag_generic.go +++ b/flag_generic.go @@ -20,6 +20,14 @@ func (f *GenericFlag) GetValue() string { 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 // provided by the user for parsing by the flag func (f *GenericFlag) Apply(set *flag.FlagSet) error { diff --git a/flag_int.go b/flag_int.go index bcaab7f..a716f39 100644 --- a/flag_int.go +++ b/flag_int.go @@ -12,6 +12,14 @@ func (f *IntFlag) GetValue() string { 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 func (f *IntFlag) Apply(set *flag.FlagSet) error { if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { diff --git a/flag_int64.go b/flag_int64.go index d8e591d..05d8506 100644 --- a/flag_int64.go +++ b/flag_int64.go @@ -12,6 +12,14 @@ func (f *Int64Flag) GetValue() string { 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 func (f *Int64Flag) Apply(set *flag.FlagSet) error { if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { diff --git a/flag_int64_slice.go b/flag_int64_slice.go index 6844e6d..2db2cea 100644 --- a/flag_int64_slice.go +++ b/flag_int64_slice.go @@ -99,6 +99,14 @@ func (f *Int64SliceFlag) GetValue() string { return strings.Join(defaultVals, ", ") } +// GetDefaultText returns the default text for this flag +func (f *Int64SliceFlag) GetDefaultText() string { + if f.DefaultText != "" { + return f.DefaultText + } + return f.GetValue() +} + // IsSliceFlag implements DocGenerationSliceFlag. func (f *Int64SliceFlag) IsSliceFlag() bool { return true diff --git a/flag_int_slice.go b/flag_int_slice.go index d3d3ea7..a2c9f21 100644 --- a/flag_int_slice.go +++ b/flag_int_slice.go @@ -110,6 +110,14 @@ func (f *IntSliceFlag) GetValue() string { return strings.Join(defaultVals, ", ") } +// GetDefaultText returns the default text for this flag +func (f *IntSliceFlag) GetDefaultText() string { + if f.DefaultText != "" { + return f.DefaultText + } + return f.GetValue() +} + // IsSliceFlag implements DocGenerationSliceFlag. func (f *IntSliceFlag) IsSliceFlag() bool { return true diff --git a/flag_string_slice.go b/flag_string_slice.go index bdeb674..f53c0e6 100644 --- a/flag_string_slice.go +++ b/flag_string_slice.go @@ -91,6 +91,14 @@ func (f *StringSliceFlag) GetValue() string { return strings.Join(defaultVals, ", ") } +// GetDefaultText returns the default text for this flag +func (f *StringSliceFlag) GetDefaultText() string { + if f.DefaultText != "" { + return f.DefaultText + } + return f.GetValue() +} + // IsSliceFlag implements DocGenerationSliceFlag. func (f *StringSliceFlag) IsSliceFlag() bool { return true diff --git a/flag_test.go b/flag_test.go index 3aafa8b..7601b4a 100644 --- a/flag_test.go +++ b/flag_test.go @@ -225,7 +225,7 @@ func TestFlagsFromEnv(t *testing.T) { f, ok := test.flag.(DocGenerationFlag) if !ok { - t.Errorf("flag %v needs to implement DocGenerationFlag to retrieve env vars", test.flag) + t.Errorf("flag %[1]q (%[1]T) needs to implement DocGenerationFlag to retrieve env vars", test.flag) } envVarSlice := f.GetEnvVars() _ = os.Setenv(envVarSlice[0], test.input) diff --git a/flag_timestamp.go b/flag_timestamp.go index 671be8b..4302f13 100644 --- a/flag_timestamp.go +++ b/flag_timestamp.go @@ -81,6 +81,14 @@ func (f *TimestampFlag) GetValue() string { 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 func (f *TimestampFlag) Apply(set *flag.FlagSet) error { if f.Layout == "" { diff --git a/flag_uint.go b/flag_uint.go index e1b0450..2214386 100644 --- a/flag_uint.go +++ b/flag_uint.go @@ -37,6 +37,14 @@ func (f *UintFlag) GetValue() string { 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. func (f *UintFlag) Get(ctx *Context) uint { return ctx.Uint(f.Name) diff --git a/flag_uint64.go b/flag_uint64.go index 593b260..e314a4a 100644 --- a/flag_uint64.go +++ b/flag_uint64.go @@ -37,6 +37,14 @@ func (f *Uint64Flag) GetValue() string { 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. func (f *Uint64Flag) Get(ctx *Context) uint64 { return ctx.Uint64(f.Name) diff --git a/flag_uint64_slice.go b/flag_uint64_slice.go index 873ad9b..ae251ac 100644 --- a/flag_uint64_slice.go +++ b/flag_uint64_slice.go @@ -91,21 +91,6 @@ func (f *Uint64SliceFlag) String() string { return FlagStringer(f) } -// TakesValue returns true of the flag takes a value, otherwise false -func (f *Uint64SliceFlag) TakesValue() bool { - return true -} - -// GetUsage returns the usage string for the flag -func (f *Uint64SliceFlag) GetUsage() string { - return f.Usage -} - -// GetCategory returns the category for the flag -func (f *Uint64SliceFlag) GetCategory() string { - return f.Category -} - // GetValue returns the flags value as string representation and an empty // string if the flag takes no value at all. func (f *Uint64SliceFlag) GetValue() string { @@ -126,11 +111,6 @@ func (f *Uint64SliceFlag) GetDefaultText() string { return f.GetValue() } -// GetEnvVars returns the env vars for this flag -func (f *Uint64SliceFlag) GetEnvVars() []string { - return f.EnvVars -} - // IsSliceFlag implements DocGenerationSliceFlag. func (f *Uint64SliceFlag) IsSliceFlag() bool { return true diff --git a/flag_uint_slice.go b/flag_uint_slice.go index 2a1fcc1..92848f2 100644 --- a/flag_uint_slice.go +++ b/flag_uint_slice.go @@ -102,21 +102,6 @@ func (f *UintSliceFlag) String() string { return FlagStringer(f) } -// TakesValue returns true of the flag takes a value, otherwise false -func (f *UintSliceFlag) TakesValue() bool { - return true -} - -// GetUsage returns the usage string for the flag -func (f *UintSliceFlag) GetUsage() string { - return f.Usage -} - -// GetCategory returns the category for the flag -func (f *UintSliceFlag) GetCategory() string { - return f.Category -} - // GetValue returns the flags value as string representation and an empty // string if the flag takes no value at all. func (f *UintSliceFlag) GetValue() string { @@ -137,11 +122,6 @@ func (f *UintSliceFlag) GetDefaultText() string { return f.GetValue() } -// GetEnvVars returns the env vars for this flag -func (f *UintSliceFlag) GetEnvVars() []string { - return f.EnvVars -} - // IsSliceFlag implements DocGenerationSliceFlag. func (f *UintSliceFlag) IsSliceFlag() bool { return true diff --git a/godoc-current.txt b/godoc-current.txt index 03b76f8..e5d2116 100644 --- a/godoc-current.txt +++ b/godoc-current.txt @@ -32,7 +32,7 @@ var ( SuggestDidYouMeanTemplate string = suggestDidYouMeanTemplate ) var AppHelpTemplate = `NAME: - {{$v := offset .Name 6}}{{wrap .Name 3}}{{if .Usage}} - {{wrap .Usage $v}}{{end}} + {{template "helpNameTemplate" .}} USAGE: {{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}} @@ -41,52 +41,39 @@ VERSION: {{.Version}}{{end}}{{end}}{{if .Description}} DESCRIPTION: - {{wrap .Description 3}}{{end}}{{if len .Authors}} + {{template "descriptionTemplate" .}}{{end}} +{{- if len .Authors}} -AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}: - {{range $index, $author := .Authors}}{{if $index}} - {{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}} +AUTHOR{{template "authorsTemplate" .}}{{end}}{{if .VisibleCommands}} -COMMANDS:{{range .VisibleCategories}}{{if .Name}} - {{.Name}}:{{range .VisibleCommands}} - {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{ $cv := offsetCommands .VisibleCommands 5}}{{range .VisibleCommands}} - {{$s := join .Names ", "}}{{$s}}{{ $sp := subtract $cv (offset $s 3) }}{{ indent $sp ""}}{{wrap .Usage $cv}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlagCategories}} +COMMANDS:{{template "visibleCommandCategoryTemplate" .}}{{end}}{{if .VisibleFlagCategories}} -GLOBAL OPTIONS:{{range .VisibleFlagCategories}} - {{if .Name}}{{.Name}} - {{end}}{{range .Flags}}{{.}} - {{end}}{{end}}{{else}}{{if .VisibleFlags}} +GLOBAL OPTIONS:{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}} -GLOBAL OPTIONS: - {{range $index, $option := .VisibleFlags}}{{if $index}} - {{end}}{{wrap $option.String 6}}{{end}}{{end}}{{end}}{{if .Copyright}} +GLOBAL OPTIONS:{{template "visibleFlagTemplate" .}}{{end}}{{if .Copyright}} COPYRIGHT: - {{wrap .Copyright 3}}{{end}} + {{template "copyrightTemplate" .}}{{end}} ` AppHelpTemplate is the text template for the Default help topic. cli.go uses text/template to render templates. You can render custom help text by setting this variable. var CommandHelpTemplate = `NAME: - {{$v := offset .HelpName 6}}{{wrap .HelpName 3}}{{if .Usage}} - {{wrap .Usage $v}}{{end}} + {{template "helpNameTemplate" .}} USAGE: - {{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Category}} + {{template "usageTemplate" .}}{{if .Category}} CATEGORY: {{.Category}}{{end}}{{if .Description}} DESCRIPTION: - {{wrap .Description 3}}{{end}}{{if .VisibleFlagCategories}} + {{template "descriptionTemplate" .}}{{end}}{{if .VisibleFlagCategories}} -OPTIONS:{{range .VisibleFlagCategories}} - {{if .Name}}{{.Name}} - {{end}}{{range .Flags}}{{.}}{{end}}{{end}}{{else}}{{if .VisibleFlags}} +OPTIONS:{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}} -OPTIONS: - {{range .VisibleFlags}}{{.}}{{end}}{{end}}{{end}} -` +OPTIONS:{{template "visibleFlagTemplate" .}}{{end}}` CommandHelpTemplate is the text template for the command help topic. cli.go uses text/template to render templates. You can render custom help text by setting this variable. @@ -145,22 +132,19 @@ var OsExiter = os.Exit os.Exit. var SubcommandHelpTemplate = `NAME: - {{.HelpName}} - {{.Usage}} + {{template "helpNameTemplate" .}} USAGE: {{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}} DESCRIPTION: - {{wrap .Description 3}}{{end}} + {{template "descriptionTemplate" .}}{{end}}{{if .VisibleCommands}} -COMMANDS:{{range .VisibleCategories}}{{if .Name}} - {{.Name}}:{{range .VisibleCommands}} - {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{ $cv := offsetCommands .VisibleCommands 5}}{{range .VisibleCommands}} - {{$s := join .Names ", "}}{{$s}}{{ $sp := subtract $cv (offset $s 3) }}{{ indent $sp ""}}{{wrap .Usage $cv}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} +COMMANDS:{{template "visibleCommandTemplate" .}}{{end}}{{if .VisibleFlagCategories}} -OPTIONS: - {{range .VisibleFlags}}{{.}}{{end}}{{end}} -` +OPTIONS:{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}} + +OPTIONS:{{template "visibleFlagTemplate" .}}{{end}}` SubcommandHelpTemplate is the text template for the subcommand help topic. cli.go uses text/template to render templates. You can render custom help text by setting this variable. @@ -586,6 +570,9 @@ func (c *Command) Run(ctx *Context) (err error) Run invokes the command given the context, parses ctx.Args() to generate command-specific flags +func (c *Command) VisibleCommands() []*Command + VisibleCommands returns a slice of the Commands with Hidden=false + func (c *Command) VisibleFlagCategories() []VisibleFlagCategory VisibleFlagCategories returns a slice containing all the visible flag categories with the flags they contain @@ -754,6 +741,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 @@ -1077,6 +1072,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 @@ -1312,6 +1310,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 @@ -1477,6 +1478,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 @@ -1817,6 +1821,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 @@ -2057,7 +2064,7 @@ func (f *Uint64SliceFlag) Get(ctx *Context) []uint64 Get returns the flag’s value in the given Context. func (f *Uint64SliceFlag) GetCategory() string - GetCategory returns the category for the flag + GetCategory returns the category of the flag func (f *Uint64SliceFlag) GetDefaultText() string GetDefaultText returns the default text for this flag @@ -2078,6 +2085,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 @@ -2091,7 +2101,7 @@ func (f *Uint64SliceFlag) String() string String returns a readable representation of this value (for usage defaults) func (f *Uint64SliceFlag) TakesValue() bool - TakesValue returns true of the flag takes a value, otherwise false + TakesValue returns true if the flag takes a value, otherwise false type UintFlag struct { Name string @@ -2216,7 +2226,7 @@ func (f *UintSliceFlag) Get(ctx *Context) []uint Get returns the flag’s value in the given Context. func (f *UintSliceFlag) GetCategory() string - GetCategory returns the category for the flag + GetCategory returns the category of the flag func (f *UintSliceFlag) GetDefaultText() string GetDefaultText returns the default text for this flag @@ -2237,6 +2247,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 @@ -2250,7 +2263,7 @@ func (f *UintSliceFlag) String() string String returns a readable representation of this value (for usage defaults) func (f *UintSliceFlag) TakesValue() bool - TakesValue returns true of the flag takes a value, otherwise false + TakesValue returns true if the flag takes a value, otherwise false type VisibleFlag interface { Flag diff --git a/zz_generated.flags.go b/zz_generated.flags.go index 68934c7..8c4e6fa 100644 --- a/zz_generated.flags.go +++ b/zz_generated.flags.go @@ -66,14 +66,6 @@ func (f *Float64SliceFlag) TakesValue() bool { 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 type GenericFlag struct { Name string @@ -143,14 +135,6 @@ func (f *GenericFlag) TakesValue() bool { 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 type Int64SliceFlag struct { Name string @@ -213,14 +197,6 @@ func (f *Int64SliceFlag) TakesValue() bool { 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 type IntSliceFlag struct { Name string @@ -283,14 +259,6 @@ func (f *IntSliceFlag) TakesValue() bool { 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 type PathFlag struct { Name string @@ -424,14 +392,6 @@ func (f *StringSliceFlag) TakesValue() bool { 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 type TimestampFlag struct { Name string @@ -503,14 +463,6 @@ func (f *TimestampFlag) TakesValue() bool { 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 type Uint64SliceFlag struct { Name string @@ -553,6 +505,26 @@ func (f *Uint64SliceFlag) IsVisible() bool { return !f.Hidden } +// GetCategory returns the category of the flag +func (f *Uint64SliceFlag) GetCategory() string { + return f.Category +} + +// GetUsage returns the usage string for the flag +func (f *Uint64SliceFlag) GetUsage() string { + return f.Usage +} + +// GetEnvVars returns the env vars for this flag +func (f *Uint64SliceFlag) GetEnvVars() []string { + return f.EnvVars +} + +// TakesValue returns true if the flag takes a value, otherwise false +func (f *Uint64SliceFlag) TakesValue() bool { + return "Uint64SliceFlag" != "BoolFlag" +} + // UintSliceFlag is a flag with type *UintSlice type UintSliceFlag struct { Name string @@ -595,6 +567,26 @@ func (f *UintSliceFlag) IsVisible() bool { return !f.Hidden } +// GetCategory returns the category of the flag +func (f *UintSliceFlag) GetCategory() string { + return f.Category +} + +// GetUsage returns the usage string for the flag +func (f *UintSliceFlag) GetUsage() string { + return f.Usage +} + +// GetEnvVars returns the env vars for this flag +func (f *UintSliceFlag) GetEnvVars() []string { + return f.EnvVars +} + +// TakesValue returns true if the flag takes a value, otherwise false +func (f *UintSliceFlag) TakesValue() bool { + return "UintSliceFlag" != "BoolFlag" +} + // BoolFlag is a flag with type bool type BoolFlag struct { Name string @@ -731,14 +723,6 @@ func (f *Float64Flag) TakesValue() bool { 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 type IntFlag struct { Name string @@ -808,14 +792,6 @@ func (f *IntFlag) TakesValue() bool { 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 type Int64Flag struct { Name string @@ -885,14 +861,6 @@ func (f *Int64Flag) TakesValue() bool { 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 type StringFlag struct { Name string @@ -1029,14 +997,6 @@ func (f *DurationFlag) TakesValue() bool { 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 type UintFlag struct { Name string @@ -1106,14 +1066,6 @@ func (f *UintFlag) TakesValue() bool { 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 type Uint64Flag struct { Name string @@ -1183,12 +1135,4 @@ func (f *Uint64Flag) TakesValue() bool { 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 diff --git a/zz_generated.flags_test.go b/zz_generated.flags_test.go index 6862afc..b7c6815 100644 --- a/zz_generated.flags_test.go +++ b/zz_generated.flags_test.go @@ -167,6 +167,18 @@ func TestUint64SliceFlag_SatisfiesFlagInterface(t *testing.T) { _ = f.Names() } +func TestUint64SliceFlag_SatisfiesRequiredFlagInterface(t *testing.T) { + var f cli.RequiredFlag = &cli.Uint64SliceFlag{} + + _ = f.IsRequired() +} + +func TestUint64SliceFlag_SatisfiesVisibleFlagInterface(t *testing.T) { + var f cli.VisibleFlag = &cli.Uint64SliceFlag{} + + _ = f.IsVisible() +} + func TestUintSliceFlag_SatisfiesFlagInterface(t *testing.T) { var f cli.Flag = &cli.UintSliceFlag{} @@ -174,6 +186,18 @@ func TestUintSliceFlag_SatisfiesFlagInterface(t *testing.T) { _ = f.Names() } +func TestUintSliceFlag_SatisfiesRequiredFlagInterface(t *testing.T) { + var f cli.RequiredFlag = &cli.UintSliceFlag{} + + _ = f.IsRequired() +} + +func TestUintSliceFlag_SatisfiesVisibleFlagInterface(t *testing.T) { + var f cli.VisibleFlag = &cli.UintSliceFlag{} + + _ = f.IsVisible() +} + func TestBoolFlag_SatisfiesFlagInterface(t *testing.T) { var f cli.Flag = &cli.BoolFlag{}