From 4a33054e1cdb0ad987ce2a2baa8365581f9561b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Feb 2023 05:15:51 +0000 Subject: [PATCH] Bump github.com/urfave/cli/v2 from 2.20.2 to 2.24.4 Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.20.2 to 2.24.4. - [Release notes](https://github.com/urfave/cli/releases) - [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/urfave/cli/compare/v2.20.2...v2.24.4) --- updated-dependencies: - dependency-name: github.com/urfave/cli/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 5 +- vendor/github.com/urfave/cli/v2/README.md | 8 +- vendor/github.com/urfave/cli/v2/app.go | 49 +++++++--- vendor/github.com/urfave/cli/v2/category.go | 17 +++- vendor/github.com/urfave/cli/v2/command.go | 18 ++-- vendor/github.com/urfave/cli/v2/context.go | 24 ++++- vendor/github.com/urfave/cli/v2/errors.go | 23 ++++- vendor/github.com/urfave/cli/v2/fish.go | 2 +- .../github.com/urfave/cli/v2/flag-spec.yaml | 16 ++++ vendor/github.com/urfave/cli/v2/flag.go | 92 ++++++++++++++----- vendor/github.com/urfave/cli/v2/flag_ext.go | 48 ++++++++++ .../urfave/cli/v2/flag_float64_slice.go | 14 ++- .../urfave/cli/v2/flag_int64_slice.go | 14 ++- .../urfave/cli/v2/flag_int_slice.go | 14 ++- .../urfave/cli/v2/flag_string_slice.go | 27 +++++- .../urfave/cli/v2/flag_uint64_slice.go | 14 ++- .../urfave/cli/v2/flag_uint_slice.go | 14 ++- .../urfave/cli/v2/godoc-current.txt | 87 ++++++++++++++++-- vendor/github.com/urfave/cli/v2/help.go | 27 ++---- .../urfave/cli/v2/zz_generated.flags.go | 16 ++++ vendor/modules.txt | 2 +- 22 files changed, 433 insertions(+), 100 deletions(-) create mode 100644 vendor/github.com/urfave/cli/v2/flag_ext.go diff --git a/go.mod b/go.mod index 98dd0322..749acd62 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/onsi/ginkgo/v2 v2.3.1 github.com/onsi/gomega v1.22.1 github.com/u-root/u-root v0.10.0 - github.com/urfave/cli/v2 v2.20.2 + github.com/urfave/cli/v2 v2.24.4 k8s.io/apimachinery v0.25.3 k8s.io/client-go v0.25.3 sigs.k8s.io/controller-runtime v0.13.0 diff --git a/go.sum b/go.sum index 6dce5ab6..cc1d0652 100644 --- a/go.sum +++ b/go.sum @@ -106,6 +106,7 @@ github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBp github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -1333,8 +1334,8 @@ github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/urfave/cli/v2 v2.16.3/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= -github.com/urfave/cli/v2 v2.20.2 h1:dKA0LUjznZpwmmbrc0pOgcLTEilnHeM8Av9Yng77gHM= -github.com/urfave/cli/v2 v2.20.2/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= +github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU= +github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= diff --git a/vendor/github.com/urfave/cli/v2/README.md b/vendor/github.com/urfave/cli/v2/README.md index eaed3563..9080aee4 100644 --- a/vendor/github.com/urfave/cli/v2/README.md +++ b/vendor/github.com/urfave/cli/v2/README.md @@ -1,9 +1,9 @@ # cli -[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://pkg.go.dev/github.com/urfave/cli/v2) -[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-urfave-cli) -[![Go Report Card](https://goreportcard.com/badge/urfave/cli)](https://goreportcard.com/report/urfave/cli) -[![codecov](https://codecov.io/gh/urfave/cli/branch/main/graph/badge.svg)](https://codecov.io/gh/urfave/cli) +[![Run Tests](https://github.com/urfave/cli/actions/workflows/cli.yml/badge.svg?branch=v2-maint)](https://github.com/urfave/cli/actions/workflows/cli.yml) +[![Go Reference](https://pkg.go.dev/badge/github.com/urfave/cli/v2.svg)](https://pkg.go.dev/github.com/urfave/cli/v2) +[![Go Report Card](https://goreportcard.com/badge/github.com/urfave/cli/v2)](https://goreportcard.com/report/github.com/urfave/cli/v2) +[![codecov](https://codecov.io/gh/urfave/cli/branch/v2-maint/graph/badge.svg?token=t9YGWLh05g)](https://app.codecov.io/gh/urfave/cli/tree/v2-maint) cli is a simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line diff --git a/vendor/github.com/urfave/cli/v2/app.go b/vendor/github.com/urfave/cli/v2/app.go index 24704e8f..4b6675a2 100644 --- a/vendor/github.com/urfave/cli/v2/app.go +++ b/vendor/github.com/urfave/cli/v2/app.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "sort" + "strings" "time" ) @@ -20,6 +21,7 @@ var ( errInvalidActionType = NewExitError("ERROR invalid Action type. "+ fmt.Sprintf("Must be `func(*Context`)` or `func(*Context) error). %s", contactSysadmin)+ fmt.Sprintf("See %s", appActionDeprecationURL), 2) + ignoreFlagPrefix = "test." // this is to ignore test flags when adding flags from other packages SuggestFlag SuggestFlagFunc = suggestFlag SuggestCommand SuggestCommandFunc = suggestCommand @@ -103,14 +105,24 @@ type App struct { // cli.go uses text/template to render templates. You can // render custom help text by setting this variable. CustomAppHelpTemplate string + // SliceFlagSeparator is used to customize the separator for SliceFlag, the default is "," + SliceFlagSeparator string + // DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false + DisableSliceFlagSeparator bool // Boolean to enable short-option handling so user can combine several // single-character bool arguments into one // i.e. foobar -o -v -> foobar -ov UseShortOptionHandling bool // Enable suggestions for commands and flags Suggest bool + // Allows global flags set by libraries which use flag.XXXVar(...) directly + // to be parsed through this library + AllowExtFlags bool + // Treat all flags as normal arguments if true + SkipFlagParsing bool - didSetup bool + didSetup bool + separator separatorSpec rootCommand *Command } @@ -195,6 +207,26 @@ func (a *App) Setup() { a.ErrWriter = os.Stderr } + if a.AllowExtFlags { + // add global flags added by other packages + flag.VisitAll(func(f *flag.Flag) { + // skip test flags + if !strings.HasPrefix(f.Name, ignoreFlagPrefix) { + a.Flags = append(a.Flags, &extFlag{f}) + } + }) + } + + if len(a.SliceFlagSeparator) != 0 { + a.separator.customized = true + a.separator.sep = a.SliceFlagSeparator + } + + if a.DisableSliceFlagSeparator { + a.separator.customized = true + a.separator.disabled = true + } + var newCommands []*Command for _, c := range a.Commands { @@ -202,8 +234,8 @@ func (a *App) Setup() { if c.HelpName != "" { cname = c.HelpName } + c.separator = a.separator c.HelpName = fmt.Sprintf("%s %s", a.HelpName, cname) - c.flagCategories = newFlagCategoriesFromFlags(c.Flags) newCommands = append(newCommands, c) } @@ -229,14 +261,7 @@ func (a *App) Setup() { } sort.Sort(a.categories.(*commandCategories)) - a.flagCategories = newFlagCategories() - for _, fl := range a.Flags { - if cf, ok := fl.(CategorizableFlag); ok { - if cf.GetCategory() != "" { - a.flagCategories.AddFlag(cf.GetCategory(), cf) - } - } - } + a.flagCategories = newFlagCategoriesFromFlags(a.Flags) if a.Metadata == nil { a.Metadata = make(map[string]interface{}) @@ -264,12 +289,14 @@ func (a *App) newRootCommand() *Command { HelpName: a.HelpName, CustomHelpTemplate: a.CustomAppHelpTemplate, categories: a.categories, + SkipFlagParsing: a.SkipFlagParsing, isRoot: true, + separator: a.separator, } } func (a *App) newFlagSet() (*flag.FlagSet, error) { - return flagSet(a.Name, a.Flags) + return flagSet(a.Name, a.Flags, a.separator) } func (a *App) useShortOptionHandling() bool { diff --git a/vendor/github.com/urfave/cli/v2/category.go b/vendor/github.com/urfave/cli/v2/category.go index 7aca0c76..ccc043c2 100644 --- a/vendor/github.com/urfave/cli/v2/category.go +++ b/vendor/github.com/urfave/cli/v2/category.go @@ -100,10 +100,23 @@ func newFlagCategories() FlagCategories { func newFlagCategoriesFromFlags(fs []Flag) FlagCategories { fc := newFlagCategories() + + var categorized bool for _, fl := range fs { if cf, ok := fl.(CategorizableFlag); ok { - if cf.GetCategory() != "" { - fc.AddFlag(cf.GetCategory(), cf) + if cat := cf.GetCategory(); cat != "" { + fc.AddFlag(cat, cf) + categorized = true + } + } + } + + if categorized == true { + for _, fl := range fs { + if cf, ok := fl.(CategorizableFlag); ok { + if cf.GetCategory() == "" { + fc.AddFlag("", fl) + } } } } diff --git a/vendor/github.com/urfave/cli/v2/command.go b/vendor/github.com/urfave/cli/v2/command.go index a63048db..f978b4a4 100644 --- a/vendor/github.com/urfave/cli/v2/command.go +++ b/vendor/github.com/urfave/cli/v2/command.go @@ -69,6 +69,8 @@ type Command struct { // if this is a root "special" command isRoot bool + + separator separatorSpec } type Commands []*Command @@ -136,6 +138,10 @@ func (c *Command) setup(ctx *Context) { newCmds = append(newCmds, scmd) } c.Subcommands = newCmds + + if c.BashComplete == nil { + c.BashComplete = DefaultCompleteWithFlags(c) + } } func (c *Command) Run(cCtx *Context, arguments ...string) (err error) { @@ -148,11 +154,7 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) { set, err := c.parseFlags(&a, cCtx.shellComplete) cCtx.flagSet = set - if c.isRoot { - if checkCompletions(cCtx) { - return nil - } - } else if checkCommandCompletions(cCtx, c.Name) { + if checkCompletions(cCtx) { return nil } @@ -203,7 +205,7 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) { cerr := cCtx.checkRequiredFlags(c.Flags) if cerr != nil { - _ = ShowSubcommandHelp(cCtx) + _ = helpCommand.Action(cCtx) return cerr } @@ -252,7 +254,7 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) { } } } - } else if cCtx.App.DefaultCommand != "" { + } else if c.isRoot && cCtx.App.DefaultCommand != "" { if dc := cCtx.App.Command(cCtx.App.DefaultCommand); dc != c { cmd = dc } @@ -275,7 +277,7 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) { } func (c *Command) newFlagSet() (*flag.FlagSet, error) { - return flagSet(c.Name, c.Flags) + return flagSet(c.Name, c.Flags, c.separator) } func (c *Command) useShortOptionHandling() bool { diff --git a/vendor/github.com/urfave/cli/v2/context.go b/vendor/github.com/urfave/cli/v2/context.go index 315c2fb5..dbf50e49 100644 --- a/vendor/github.com/urfave/cli/v2/context.go +++ b/vendor/github.com/urfave/cli/v2/context.go @@ -82,7 +82,27 @@ func (cCtx *Context) IsSet(name string) bool { func (cCtx *Context) LocalFlagNames() []string { var names []string cCtx.flagSet.Visit(makeFlagNameVisitor(&names)) - return names + // Check the flags which have been set via env or file + if cCtx.Command != nil && cCtx.Command.Flags != nil { + for _, f := range cCtx.Command.Flags { + if f.IsSet() { + names = append(names, f.Names()...) + } + } + } + + // Sort out the duplicates since flag could be set via multiple + // paths + m := map[string]struct{}{} + var unames []string + for _, name := range names { + if _, ok := m[name]; !ok { + m[name] = struct{}{} + unames = append(unames, name) + } + } + + return unames } // FlagNames returns a slice of flag names used by the this context and all of @@ -90,7 +110,7 @@ func (cCtx *Context) LocalFlagNames() []string { func (cCtx *Context) FlagNames() []string { var names []string for _, pCtx := range cCtx.Lineage() { - pCtx.flagSet.Visit(makeFlagNameVisitor(&names)) + names = append(names, pCtx.LocalFlagNames()...) } return names } diff --git a/vendor/github.com/urfave/cli/v2/errors.go b/vendor/github.com/urfave/cli/v2/errors.go index 8f641fb6..a818727d 100644 --- a/vendor/github.com/urfave/cli/v2/errors.go +++ b/vendor/github.com/urfave/cli/v2/errors.go @@ -83,7 +83,7 @@ type ExitCoder interface { type exitError struct { exitCode int - message interface{} + err error } // NewExitError calls Exit to create a new ExitCoder. @@ -98,23 +98,38 @@ func NewExitError(message interface{}, exitCode int) ExitCoder { // // This is the simplest way to trigger a non-zero exit code for an App without // having to call os.Exit manually. During testing, this behavior can be avoided -// by overiding the ExitErrHandler function on an App or the package-global +// by overriding the ExitErrHandler function on an App or the package-global // OsExiter function. func Exit(message interface{}, exitCode int) ExitCoder { + var err error + + switch e := message.(type) { + case ErrorFormatter: + err = fmt.Errorf("%+v", message) + case error: + err = e + default: + err = fmt.Errorf("%+v", message) + } + return &exitError{ - message: message, + err: err, exitCode: exitCode, } } func (ee *exitError) Error() string { - return fmt.Sprintf("%v", ee.message) + return ee.err.Error() } func (ee *exitError) ExitCode() int { return ee.exitCode } +func (ee *exitError) Unwrap() error { + return ee.err +} + // HandleExitCoder handles errors implementing ExitCoder by printing their // message and calling OsExiter with the given exit code. // diff --git a/vendor/github.com/urfave/cli/v2/fish.go b/vendor/github.com/urfave/cli/v2/fish.go index eec3253c..909dfc5a 100644 --- a/vendor/github.com/urfave/cli/v2/fish.go +++ b/vendor/github.com/urfave/cli/v2/fish.go @@ -98,7 +98,7 @@ func (a *App) prepareFishCommands(commands []*Command, allCommands *[]string, pr a.prepareFishFlags(command.VisibleFlags(), command.Names())..., ) - // recursevly iterate subcommands + // recursively iterate subcommands if len(command.Subcommands) > 0 { completions = append( completions, diff --git a/vendor/github.com/urfave/cli/v2/flag-spec.yaml b/vendor/github.com/urfave/cli/v2/flag-spec.yaml index 76480ba4..03d82e70 100644 --- a/vendor/github.com/urfave/cli/v2/flag-spec.yaml +++ b/vendor/github.com/urfave/cli/v2/flag-spec.yaml @@ -7,6 +7,8 @@ flag_types: - name: Count type: int pointer: true + - name: DisableDefaultText + type: bool - name: Action type: "func(*Context, bool) error" float64: @@ -18,6 +20,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []float64) error" int: @@ -31,6 +35,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []int) error" int64: @@ -44,6 +50,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []int64) error" uint: @@ -57,6 +65,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []uint) error" uint64: @@ -70,6 +80,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []uint64) error" string: @@ -83,10 +95,14 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: TakesFile type: bool - name: Action type: "func(*Context, []string) error" + - name: KeepSpace + type: bool time.Duration: struct_fields: - name: Action diff --git a/vendor/github.com/urfave/cli/v2/flag.go b/vendor/github.com/urfave/cli/v2/flag.go index a6fea1c4..4d04de3d 100644 --- a/vendor/github.com/urfave/cli/v2/flag.go +++ b/vendor/github.com/urfave/cli/v2/flag.go @@ -4,7 +4,8 @@ import ( "errors" "flag" "fmt" - "io/ioutil" + "io" + "os" "regexp" "runtime" "strings" @@ -14,6 +15,11 @@ import ( const defaultPlaceholder = "value" +const ( + defaultSliceFlagSeparator = "," + disableSliceFlagSeparator = false +) + var ( slPfx = fmt.Sprintf("sl:::%d:::", time.Now().UTC().UnixNano()) @@ -28,18 +34,20 @@ var BashCompletionFlag Flag = &BoolFlag{ // VersionFlag prints the version for the application var VersionFlag Flag = &BoolFlag{ - Name: "version", - Aliases: []string{"v"}, - Usage: "print the version", + Name: "version", + Aliases: []string{"v"}, + Usage: "print the version", + DisableDefaultText: true, } // HelpFlag prints the help for all commands and subcommands. // Set to nil to disable the flag. The subcommand // will still be added unless HideHelp or HideHelpCommand is set to true. var HelpFlag Flag = &BoolFlag{ - Name: "help", - Aliases: []string{"h"}, - Usage: "show help", + Name: "help", + Aliases: []string{"h"}, + Usage: "show help", + DisableDefaultText: true, } // FlagStringer converts a flag definition to a string. This is used by help @@ -159,15 +167,18 @@ type Countable interface { Count() int } -func flagSet(name string, flags []Flag) (*flag.FlagSet, error) { +func flagSet(name string, flags []Flag, spec separatorSpec) (*flag.FlagSet, error) { set := flag.NewFlagSet(name, flag.ContinueOnError) for _, f := range flags { + if c, ok := f.(customizedSeparator); ok { + c.WithSeparatorSpec(spec) + } if err := f.Apply(set); err != nil { return nil, err } } - set.SetOutput(ioutil.Discard) + set.SetOutput(io.Discard) return set, nil } @@ -268,19 +279,23 @@ func prefixedNames(names []string, placeholder string) string { return prefixed } -func withEnvHint(envVars []string, str string) string { - envText := "" +func envFormat(envVars []string, prefix, sep, suffix string) string { if len(envVars) > 0 { - prefix := "$" - suffix := "" - sep := ", $" - if runtime.GOOS == "windows" { - prefix = "%" - suffix = "%" - sep = "%, %" - } + return fmt.Sprintf(" [%s%s%s]", prefix, strings.Join(envVars, sep), suffix) + } + return "" +} - envText = fmt.Sprintf(" [%s%s%s]", prefix, strings.Join(envVars, sep), suffix) +func defaultEnvFormat(envVars []string) string { + return envFormat(envVars, "$", ", $", "") +} + +func withEnvHint(envVars []string, str string) string { + envText := "" + if runtime.GOOS != "windows" || os.Getenv("PSHOME") != "" { + envText = defaultEnvFormat(envVars) + } else { + envText = envFormat(envVars, "%", "%, %", "%") } return str + envText } @@ -327,8 +342,13 @@ func stringifyFlag(f Flag) string { defaultValueString := "" - if s := df.GetDefaultText(); s != "" { - defaultValueString = fmt.Sprintf(formatDefault("%s"), s) + // set default text for all flags except bool flags + // for bool flags display default text if DisableDefaultText is not + // set + if bf, ok := f.(*BoolFlag); !ok || !bf.DisableDefaultText { + if s := df.GetDefaultText(); s != "" { + defaultValueString = fmt.Sprintf(formatDefault("%s"), s) + } } usageWithDefault := strings.TrimSpace(usage + defaultValueString) @@ -364,7 +384,7 @@ func flagFromEnvOrFile(envVars []string, filePath string) (value string, fromWhe } for _, fileVar := range strings.Split(filePath, ",") { if fileVar != "" { - if data, err := ioutil.ReadFile(fileVar); err == nil { + if data, err := os.ReadFile(fileVar); err == nil { return string(data), fmt.Sprintf("file %q", filePath), true } } @@ -372,6 +392,28 @@ func flagFromEnvOrFile(envVars []string, filePath string) (value string, fromWhe return "", "", false } -func flagSplitMultiValues(val string) []string { - return strings.Split(val, ",") +type customizedSeparator interface { + WithSeparatorSpec(separatorSpec) +} + +type separatorSpec struct { + sep string + disabled bool + customized bool +} + +func (s separatorSpec) flagSplitMultiValues(val string) []string { + var ( + disabled bool = s.disabled + sep string = s.sep + ) + if !s.customized { + disabled = disableSliceFlagSeparator + sep = defaultSliceFlagSeparator + } + if disabled { + return []string{val} + } + + return strings.Split(val, sep) } diff --git a/vendor/github.com/urfave/cli/v2/flag_ext.go b/vendor/github.com/urfave/cli/v2/flag_ext.go new file mode 100644 index 00000000..64da59ea --- /dev/null +++ b/vendor/github.com/urfave/cli/v2/flag_ext.go @@ -0,0 +1,48 @@ +package cli + +import "flag" + +type extFlag struct { + f *flag.Flag +} + +func (e *extFlag) Apply(fs *flag.FlagSet) error { + fs.Var(e.f.Value, e.f.Name, e.f.Usage) + return nil +} + +func (e *extFlag) Names() []string { + return []string{e.f.Name} +} + +func (e *extFlag) IsSet() bool { + return false +} + +func (e *extFlag) String() string { + return FlagStringer(e) +} + +func (e *extFlag) IsVisible() bool { + return true +} + +func (e *extFlag) TakesValue() bool { + return false +} + +func (e *extFlag) GetUsage() string { + return e.f.Usage +} + +func (e *extFlag) GetValue() string { + return e.f.Value.String() +} + +func (e *extFlag) GetDefaultText() string { + return e.f.DefValue +} + +func (e *extFlag) GetEnvVars() []string { + return nil +} diff --git a/vendor/github.com/urfave/cli/v2/flag_float64_slice.go b/vendor/github.com/urfave/cli/v2/flag_float64_slice.go index 413aa50e..0bc4612c 100644 --- a/vendor/github.com/urfave/cli/v2/flag_float64_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_float64_slice.go @@ -11,6 +11,7 @@ import ( // Float64Slice wraps []float64 to satisfy flag.Value type Float64Slice struct { slice []float64 + separator separatorSpec hasBeenSet bool } @@ -29,6 +30,10 @@ func (f *Float64Slice) clone() *Float64Slice { return n } +func (f *Float64Slice) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Set parses the value into a float64 and appends it to the list of values func (f *Float64Slice) Set(value string) error { if !f.hasBeenSet { @@ -43,7 +48,7 @@ func (f *Float64Slice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range f.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseFloat(strings.TrimSpace(s), 64) if err != nil { return err @@ -148,11 +153,12 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(Float64Slice) + setValue.WithSeparatorSpec(f.separator) } if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { if val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as float64 slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -172,6 +178,10 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *Float64SliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *Float64SliceFlag) Get(ctx *Context) []float64 { return ctx.Float64Slice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_int64_slice.go b/vendor/github.com/urfave/cli/v2/flag_int64_slice.go index c45c43d3..d45c2dd4 100644 --- a/vendor/github.com/urfave/cli/v2/flag_int64_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_int64_slice.go @@ -11,6 +11,7 @@ import ( // Int64Slice wraps []int64 to satisfy flag.Value type Int64Slice struct { slice []int64 + separator separatorSpec hasBeenSet bool } @@ -29,6 +30,10 @@ func (i *Int64Slice) clone() *Int64Slice { return n } +func (i *Int64Slice) WithSeparatorSpec(spec separatorSpec) { + i.separator = spec +} + // Set parses the value into an integer and appends it to the list of values func (i *Int64Slice) Set(value string) error { if !i.hasBeenSet { @@ -43,7 +48,7 @@ func (i *Int64Slice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range i.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseInt(strings.TrimSpace(s), 0, 64) if err != nil { return err @@ -149,10 +154,11 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(Int64Slice) + setValue.WithSeparatorSpec(f.separator) } if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as int64 slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -171,6 +177,10 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *Int64SliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *Int64SliceFlag) Get(ctx *Context) []int64 { return ctx.Int64Slice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_int_slice.go b/vendor/github.com/urfave/cli/v2/flag_int_slice.go index d4006e59..da9c09bc 100644 --- a/vendor/github.com/urfave/cli/v2/flag_int_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_int_slice.go @@ -11,6 +11,7 @@ import ( // IntSlice wraps []int to satisfy flag.Value type IntSlice struct { slice []int + separator separatorSpec hasBeenSet bool } @@ -40,6 +41,10 @@ func (i *IntSlice) SetInt(value int) { i.slice = append(i.slice, value) } +func (i *IntSlice) WithSeparatorSpec(spec separatorSpec) { + i.separator = spec +} + // Set parses the value into an integer and appends it to the list of values func (i *IntSlice) Set(value string) error { if !i.hasBeenSet { @@ -54,7 +59,7 @@ func (i *IntSlice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range i.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseInt(strings.TrimSpace(s), 0, 64) if err != nil { return err @@ -160,10 +165,11 @@ func (f *IntSliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(IntSlice) + setValue.WithSeparatorSpec(f.separator) } if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as int slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -182,6 +188,10 @@ func (f *IntSliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *IntSliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *IntSliceFlag) Get(ctx *Context) []int { return ctx.IntSlice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_string_slice.go b/vendor/github.com/urfave/cli/v2/flag_string_slice.go index baca2a2f..28f4798f 100644 --- a/vendor/github.com/urfave/cli/v2/flag_string_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_string_slice.go @@ -11,7 +11,9 @@ import ( // StringSlice wraps a []string to satisfy flag.Value type StringSlice struct { slice []string + separator separatorSpec hasBeenSet bool + keepSpace bool } // NewStringSlice creates a *StringSlice with default values @@ -43,13 +45,20 @@ func (s *StringSlice) Set(value string) error { return nil } - for _, t := range flagSplitMultiValues(value) { - s.slice = append(s.slice, strings.TrimSpace(t)) + for _, t := range s.separator.flagSplitMultiValues(value) { + if !s.keepSpace { + t = strings.TrimSpace(t) + } + s.slice = append(s.slice, t) } return nil } +func (s *StringSlice) WithSeparatorSpec(spec separatorSpec) { + s.separator = spec +} + // String returns a readable representation of this value (for usage defaults) func (s *StringSlice) String() string { return fmt.Sprintf("%s", s.slice) @@ -141,11 +150,17 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(StringSlice) + setValue.WithSeparatorSpec(f.separator) } + setValue.keepSpace = f.KeepSpace + if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { - for _, s := range flagSplitMultiValues(val) { - if err := setValue.Set(strings.TrimSpace(s)); err != nil { + for _, s := range f.separator.flagSplitMultiValues(val) { + if !f.KeepSpace { + s = strings.TrimSpace(s) + } + if err := setValue.Set(s); err != nil { return fmt.Errorf("could not parse %q as string value from %s for flag %s: %s", val, source, f.Name, err) } } @@ -163,6 +178,10 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *StringSliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *StringSliceFlag) Get(ctx *Context) []string { return ctx.StringSlice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_uint64_slice.go b/vendor/github.com/urfave/cli/v2/flag_uint64_slice.go index 61bb30b5..e845dd52 100644 --- a/vendor/github.com/urfave/cli/v2/flag_uint64_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_uint64_slice.go @@ -11,6 +11,7 @@ import ( // Uint64Slice wraps []int64 to satisfy flag.Value type Uint64Slice struct { slice []uint64 + separator separatorSpec hasBeenSet bool } @@ -43,7 +44,7 @@ func (i *Uint64Slice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range i.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseUint(strings.TrimSpace(s), 0, 64) if err != nil { return err @@ -55,6 +56,10 @@ func (i *Uint64Slice) Set(value string) error { return nil } +func (i *Uint64Slice) WithSeparatorSpec(spec separatorSpec) { + i.separator = spec +} + // String returns a readable representation of this value (for usage defaults) func (i *Uint64Slice) String() string { v := i.slice @@ -153,10 +158,11 @@ func (f *Uint64SliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(Uint64Slice) + setValue.WithSeparatorSpec(f.separator) } if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as uint64 slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -175,6 +181,10 @@ func (f *Uint64SliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *Uint64SliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *Uint64SliceFlag) Get(ctx *Context) []uint64 { return ctx.Uint64Slice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_uint_slice.go b/vendor/github.com/urfave/cli/v2/flag_uint_slice.go index 363aa657..d2aed480 100644 --- a/vendor/github.com/urfave/cli/v2/flag_uint_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_uint_slice.go @@ -11,6 +11,7 @@ import ( // UintSlice wraps []int to satisfy flag.Value type UintSlice struct { slice []uint + separator separatorSpec hasBeenSet bool } @@ -54,7 +55,7 @@ func (i *UintSlice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range i.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseUint(strings.TrimSpace(s), 0, 32) if err != nil { return err @@ -66,6 +67,10 @@ func (i *UintSlice) Set(value string) error { return nil } +func (i *UintSlice) WithSeparatorSpec(spec separatorSpec) { + i.separator = spec +} + // String returns a readable representation of this value (for usage defaults) func (i *UintSlice) String() string { v := i.slice @@ -164,10 +169,11 @@ func (f *UintSliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(UintSlice) + setValue.WithSeparatorSpec(f.separator) } if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as uint slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -186,6 +192,10 @@ func (f *UintSliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *UintSliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *UintSliceFlag) Get(ctx *Context) []uint { return ctx.UintSlice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/godoc-current.txt b/vendor/github.com/urfave/cli/v2/godoc-current.txt index 80344ece..bd5e1def 100644 --- a/vendor/github.com/urfave/cli/v2/godoc-current.txt +++ b/vendor/github.com/urfave/cli/v2/godoc-current.txt @@ -316,12 +316,21 @@ type App struct { // cli.go uses text/template to render templates. You can // render custom help text by setting this variable. CustomAppHelpTemplate string + // SliceFlagSeparator is used to customize the separator for SliceFlag, the default is "," + SliceFlagSeparator string + // DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false + DisableSliceFlagSeparator bool // Boolean to enable short-option handling so user can combine several // single-character bool arguments into one // i.e. foobar -o -v -> foobar -ov UseShortOptionHandling bool // Enable suggestions for commands and flags Suggest bool + // Allows global flags set by libraries which use flag.XXXVar(...) directly + // to be parsed through this library + AllowExtFlags bool + // Treat all flags as normal arguments if true + SkipFlagParsing bool // Has unexported fields. } @@ -446,6 +455,8 @@ type BoolFlag struct { Count *int + DisableDefaultText bool + Action func(*Context, bool) error // Has unexported fields. } @@ -841,7 +852,7 @@ func Exit(message interface{}, exitCode int) ExitCoder This is the simplest way to trigger a non-zero exit code for an App without having to call os.Exit manually. During testing, this behavior - can be avoided by overiding the ExitErrHandler function on an App or the + can be avoided by overriding the ExitErrHandler function on an App or the package-global OsExiter function. func NewExitError(message interface{}, exitCode int) ExitCoder @@ -872,18 +883,20 @@ var BashCompletionFlag Flag = &BoolFlag{ BashCompletionFlag enables bash-completion for all commands and subcommands var HelpFlag Flag = &BoolFlag{ - Name: "help", - Aliases: []string{"h"}, - Usage: "show help", + Name: "help", + Aliases: []string{"h"}, + Usage: "show help", + DisableDefaultText: true, } HelpFlag prints the help for all commands and subcommands. Set to nil to disable the flag. The subcommand will still be added unless HideHelp or HideHelpCommand is set to true. var VersionFlag Flag = &BoolFlag{ - Name: "version", - Aliases: []string{"v"}, - Usage: "print the version", + Name: "version", + Aliases: []string{"v"}, + Usage: "print the version", + DisableDefaultText: true, } VersionFlag prints the version for the application @@ -1025,6 +1038,8 @@ func (f *Float64Slice) String() string func (f *Float64Slice) Value() []float64 Value returns the slice of float64s set by this flag +func (f *Float64Slice) WithSeparatorSpec(spec separatorSpec) + type Float64SliceFlag struct { Name string @@ -1100,6 +1115,8 @@ func (f *Float64SliceFlag) String() string func (f *Float64SliceFlag) TakesValue() bool TakesValue returns true if the flag takes a value, otherwise false +func (f *Float64SliceFlag) WithSeparatorSpec(spec separatorSpec) + type Generic interface { Set(value string) error String() string @@ -1266,6 +1283,8 @@ func (i *Int64Slice) String() string func (i *Int64Slice) Value() []int64 Value returns the slice of ints set by this flag +func (i *Int64Slice) WithSeparatorSpec(spec separatorSpec) + type Int64SliceFlag struct { Name string @@ -1341,6 +1360,8 @@ func (f *Int64SliceFlag) String() string func (f *Int64SliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *Int64SliceFlag) WithSeparatorSpec(spec separatorSpec) + type IntFlag struct { Name string @@ -1436,6 +1457,8 @@ func (i *IntSlice) String() string func (i *IntSlice) Value() []int Value returns the slice of ints set by this flag +func (i *IntSlice) WithSeparatorSpec(spec separatorSpec) + type IntSliceFlag struct { Name string @@ -1511,6 +1534,8 @@ func (f *IntSliceFlag) String() string func (f *IntSliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *IntSliceFlag) WithSeparatorSpec(spec separatorSpec) + type InvalidFlagAccessFunc func(*Context, string) InvalidFlagAccessFunc is executed when an invalid flag is accessed from the context. @@ -1779,6 +1804,8 @@ func (s *StringSlice) String() string func (s *StringSlice) Value() []string Value returns the slice of strings set by this flag +func (s *StringSlice) WithSeparatorSpec(spec separatorSpec) + type StringSliceFlag struct { Name string @@ -1800,6 +1827,8 @@ type StringSliceFlag struct { TakesFile bool Action func(*Context, []string) error + + KeepSpace bool // Has unexported fields. } StringSliceFlag is a flag with type *StringSlice @@ -1856,6 +1885,8 @@ func (f *StringSliceFlag) String() string func (f *StringSliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *StringSliceFlag) WithSeparatorSpec(spec separatorSpec) + type SuggestCommandFunc func(commands []*Command, provided string) string type SuggestFlagFunc func(flags []Flag, provided string, hideHelp bool) string @@ -2050,6 +2081,8 @@ func (i *Uint64Slice) String() string func (i *Uint64Slice) Value() []uint64 Value returns the slice of ints set by this flag +func (i *Uint64Slice) WithSeparatorSpec(spec separatorSpec) + type Uint64SliceFlag struct { Name string @@ -2116,6 +2149,8 @@ func (f *Uint64SliceFlag) String() string func (f *Uint64SliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *Uint64SliceFlag) WithSeparatorSpec(spec separatorSpec) + type UintFlag struct { Name string @@ -2211,6 +2246,8 @@ func (i *UintSlice) String() string func (i *UintSlice) Value() []uint Value returns the slice of ints set by this flag +func (i *UintSlice) WithSeparatorSpec(spec separatorSpec) + type UintSliceFlag struct { Name string @@ -2277,6 +2314,8 @@ func (f *UintSliceFlag) String() string func (f *UintSliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *UintSliceFlag) WithSeparatorSpec(spec separatorSpec) + type VisibleFlag interface { Flag @@ -2404,6 +2443,9 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error Apply saves the flagSet for later usage calls, then calls the wrapped Float64SliceFlag.Apply +func (f *Float64SliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error + ApplyInputSourceValue applies a Float64Slice value if required + type GenericFlag struct { *cli.GenericFlag // Has unexported fields. @@ -2425,11 +2467,16 @@ type InputSourceContext interface { Source() string Int(name string) (int, error) + Int64(name string) (int64, error) + Uint(name string) (uint, error) + Uint64(name string) (uint64, error) Duration(name string) (time.Duration, error) Float64(name string) (float64, error) String(name string) (string, error) StringSlice(name string) ([]string, error) IntSlice(name string) ([]int, error) + Int64Slice(name string) ([]int64, error) + Float64Slice(name string) ([]float64, error) Generic(name string) (cli.Generic, error) Bool(name string) (bool, error) @@ -2473,6 +2520,8 @@ func (f *Int64Flag) Apply(set *flag.FlagSet) error Apply saves the flagSet for later usage calls, then calls the wrapped Int64Flag.Apply +func (f *Int64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error + type Int64SliceFlag struct { *cli.Int64SliceFlag // Has unexported fields. @@ -2487,6 +2536,9 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error Apply saves the flagSet for later usage calls, then calls the wrapped Int64SliceFlag.Apply +func (f *Int64SliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error + ApplyInputSourceValue applies a Int64Slice value if required + type IntFlag struct { *cli.IntFlag // Has unexported fields. @@ -2540,6 +2592,10 @@ func (fsm *MapInputSource) Duration(name string) (time.Duration, error) func (fsm *MapInputSource) Float64(name string) (float64, error) Float64 returns an float64 from the map if it exists otherwise returns 0 +func (fsm *MapInputSource) Float64Slice(name string) ([]float64, error) + Float64Slice returns an []float64 from the map if it exists otherwise + returns nil + func (fsm *MapInputSource) Generic(name string) (cli.Generic, error) Generic returns an cli.Generic from the map if it exists otherwise returns nil @@ -2547,6 +2603,13 @@ func (fsm *MapInputSource) Generic(name string) (cli.Generic, error) func (fsm *MapInputSource) Int(name string) (int, error) Int returns an int from the map if it exists otherwise returns 0 +func (fsm *MapInputSource) Int64(name string) (int64, error) + Int64 returns an int64 from the map if it exists otherwise returns 0 + +func (fsm *MapInputSource) Int64Slice(name string) ([]int64, error) + Int64Slice returns an []int64 from the map if it exists otherwise returns + nil + func (fsm *MapInputSource) IntSlice(name string) ([]int, error) IntSlice returns an []int from the map if it exists otherwise returns nil @@ -2561,6 +2624,12 @@ func (fsm *MapInputSource) StringSlice(name string) ([]string, error) StringSlice returns an []string from the map if it exists otherwise returns nil +func (fsm *MapInputSource) Uint(name string) (uint, error) + Int64 returns an int64 from the map if it exists otherwise returns 0 + +func (fsm *MapInputSource) Uint64(name string) (uint64, error) + UInt64 returns an uint64 from the map if it exists otherwise returns 0 + type PathFlag struct { *cli.PathFlag // Has unexported fields. @@ -2626,6 +2695,8 @@ func (f *Uint64Flag) Apply(set *flag.FlagSet) error Apply saves the flagSet for later usage calls, then calls the wrapped Uint64Flag.Apply +func (f *Uint64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error + type UintFlag struct { *cli.UintFlag // Has unexported fields. @@ -2640,3 +2711,5 @@ func (f *UintFlag) Apply(set *flag.FlagSet) error Apply saves the flagSet for later usage calls, then calls the wrapped UintFlag.Apply +func (f *UintFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error + diff --git a/vendor/github.com/urfave/cli/v2/help.go b/vendor/github.com/urfave/cli/v2/help.go index 466ff347..c7b8f55a 100644 --- a/vendor/github.com/urfave/cli/v2/help.go +++ b/vendor/github.com/urfave/cli/v2/help.go @@ -60,7 +60,7 @@ var helpCommand = &Command{ } // Case 1 & 2 - // Special case when running help on main app itself as opposed to indivdual + // Special case when running help on main app itself as opposed to individual // commands/subcommands if cCtx.parentContext.App == nil { _ = ShowAppHelp(cCtx) @@ -188,7 +188,7 @@ func printFlagSuggestions(lastArg string, flags []Flag, writer io.Writer) { // this will get total count utf8 letters in flag name count := utf8.RuneCountInString(name) if count > 2 { - count = 2 // resuse this count to generate single - or -- in flag completion + count = 2 // reuse this count to generate single - or -- in flag completion } // if flag name has more than one utf8 letter and last argument in cli has -- prefix then // skip flag completion for short flags example -v or -x @@ -227,7 +227,7 @@ func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context) { return } - printCommandSuggestions(cCtx.App.Commands, cCtx.App.Writer) + printCommandSuggestions(cCtx.Command.Subcommands, cCtx.App.Writer) } } @@ -246,7 +246,7 @@ func ShowCommandHelp(ctx *Context, command string) error { } for _, c := range commands { if c.HasName(command) { - if !ctx.App.HideHelpCommand && !c.HasName(helpName) && len(c.Subcommands) != 0 { + if !ctx.App.HideHelpCommand && !c.HasName(helpName) && len(c.Subcommands) != 0 && c.Command(helpName) == nil { c.Subcommands = append(c.Subcommands, helpCommandDontUse) } if !ctx.App.HideHelp && HelpFlag != nil { @@ -308,15 +308,15 @@ func printVersion(cCtx *Context) { // ShowCompletions prints the lists of commands within a given context func ShowCompletions(cCtx *Context) { - a := cCtx.App - if a != nil && a.BashComplete != nil { - a.BashComplete(cCtx) + c := cCtx.Command + if c != nil && c.BashComplete != nil { + c.BashComplete(cCtx) } } // ShowCommandCompletions prints the custom completions for a given command func ShowCommandCompletions(ctx *Context, command string) { - c := ctx.App.Command(command) + c := ctx.Command.Command(command) if c != nil { if c.BashComplete != nil { c.BashComplete(ctx) @@ -453,7 +453,7 @@ func checkCompletions(cCtx *Context) bool { if args := cCtx.Args(); args.Present() { name := args.First() - if cmd := cCtx.App.Command(name); cmd != nil { + if cmd := cCtx.Command.Command(name); cmd != nil { // let the command handle the completion return false } @@ -463,15 +463,6 @@ func checkCompletions(cCtx *Context) bool { return true } -func checkCommandCompletions(c *Context, name string) bool { - if !c.shellComplete { - return false - } - - ShowCommandCompletions(c, name) - return true -} - func subtract(a, b int) int { return a - b } diff --git a/vendor/github.com/urfave/cli/v2/zz_generated.flags.go b/vendor/github.com/urfave/cli/v2/zz_generated.flags.go index 7d0a267f..73e77145 100644 --- a/vendor/github.com/urfave/cli/v2/zz_generated.flags.go +++ b/vendor/github.com/urfave/cli/v2/zz_generated.flags.go @@ -25,6 +25,8 @@ type Float64SliceFlag struct { defaultValue *Float64Slice + separator separatorSpec + Action func(*Context, []float64) error } @@ -120,6 +122,8 @@ type Int64SliceFlag struct { defaultValue *Int64Slice + separator separatorSpec + Action func(*Context, []int64) error } @@ -164,6 +168,8 @@ type IntSliceFlag struct { defaultValue *IntSlice + separator separatorSpec + Action func(*Context, []int) error } @@ -259,9 +265,13 @@ type StringSliceFlag struct { defaultValue *StringSlice + separator separatorSpec + TakesFile bool Action func(*Context, []string) error + + KeepSpace bool } // IsSet returns whether or not the flag has been set through env or file @@ -358,6 +368,8 @@ type Uint64SliceFlag struct { defaultValue *Uint64Slice + separator separatorSpec + Action func(*Context, []uint64) error } @@ -402,6 +414,8 @@ type UintSliceFlag struct { defaultValue *UintSlice + separator separatorSpec + Action func(*Context, []uint) error } @@ -448,6 +462,8 @@ type BoolFlag struct { Count *int + DisableDefaultText bool + Action func(*Context, bool) error } diff --git a/vendor/modules.txt b/vendor/modules.txt index ab569ab1..d123cac5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -277,7 +277,7 @@ github.com/spf13/pflag # github.com/u-root/u-root v0.10.0 ## explicit; go 1.17 github.com/u-root/u-root/pkg/shlex -# github.com/urfave/cli/v2 v2.20.2 +# github.com/urfave/cli/v2 v2.24.4 ## explicit; go 1.18 github.com/urfave/cli/v2 # github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673