From a3dc324b19a2651cd651ccfa5bba9a380496ab6f Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 1 Nov 2022 10:46:03 +0200 Subject: [PATCH] vendor: update github.com/urfave/cli/v2 from 2.20.3 to 2.23.0 --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/urfave/cli/v2/app.go | 16 +++++++ vendor/github.com/urfave/cli/v2/command.go | 2 +- vendor/github.com/urfave/cli/v2/errors.go | 23 +++++++-- vendor/github.com/urfave/cli/v2/fish.go | 2 +- vendor/github.com/urfave/cli/v2/flag.go | 4 +- vendor/github.com/urfave/cli/v2/flag_ext.go | 48 +++++++++++++++++++ .../urfave/cli/v2/godoc-current.txt | 4 +- vendor/github.com/urfave/cli/v2/help.go | 4 +- vendor/modules.txt | 2 +- 11 files changed, 97 insertions(+), 14 deletions(-) create mode 100644 vendor/github.com/urfave/cli/v2/flag_ext.go diff --git a/go.mod b/go.mod index 475ed70f4..e8dbe3653 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/influxdata/influxdb v1.10.0 github.com/klauspost/compress v1.15.12 github.com/prometheus/prometheus v1.8.2-0.20201119142752-3ad25a6dc3d9 - github.com/urfave/cli/v2 v2.20.3 + github.com/urfave/cli/v2 v2.23.0 github.com/valyala/fastjson v1.6.3 github.com/valyala/fastrand v1.1.0 github.com/valyala/fasttemplate v1.2.2 diff --git a/go.sum b/go.sum index 8f6e0996a..0f9c5e9bb 100644 --- a/go.sum +++ b/go.sum @@ -829,8 +829,8 @@ github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMW github.com/uber/jaeger-lib v2.4.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli/v2 v2.20.3 h1:lOgGidH/N5loaigd9HjFsOIhXSTrzl7tBpHswZ428w4= -github.com/urfave/cli/v2 v2.20.3/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= +github.com/urfave/cli/v2 v2.23.0 h1:pkly7gKIeYv3olPAeNajNpLjeJrmTPYCoZWaV+2VfvE= +github.com/urfave/cli/v2 v2.23.0/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.30.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus= diff --git a/vendor/github.com/urfave/cli/v2/app.go b/vendor/github.com/urfave/cli/v2/app.go index 24704e8f7..3fb5c169a 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,6 +105,8 @@ 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 // Boolean to enable short-option handling so user can combine several // single-character bool arguments into one // i.e. foobar -o -v -> foobar -ov @@ -195,6 +199,14 @@ func (a *App) Setup() { a.ErrWriter = os.Stderr } + // 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}) + } + }) + var newCommands []*Command for _, c := range a.Commands { @@ -241,6 +253,10 @@ func (a *App) Setup() { if a.Metadata == nil { a.Metadata = make(map[string]interface{}) } + + if len(a.SliceFlagSeparator) != 0 { + defaultSliceFlagSeparator = a.SliceFlagSeparator + } } func (a *App) newRootCommand() *Command { diff --git a/vendor/github.com/urfave/cli/v2/command.go b/vendor/github.com/urfave/cli/v2/command.go index a63048dbd..c5939d4ec 100644 --- a/vendor/github.com/urfave/cli/v2/command.go +++ b/vendor/github.com/urfave/cli/v2/command.go @@ -252,7 +252,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 } diff --git a/vendor/github.com/urfave/cli/v2/errors.go b/vendor/github.com/urfave/cli/v2/errors.go index 8f641fb64..a818727db 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 eec3253cd..909dfc5a2 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.go b/vendor/github.com/urfave/cli/v2/flag.go index 7535424c0..b66a75da5 100644 --- a/vendor/github.com/urfave/cli/v2/flag.go +++ b/vendor/github.com/urfave/cli/v2/flag.go @@ -15,6 +15,8 @@ import ( const defaultPlaceholder = "value" +var defaultSliceFlagSeparator = "," + var ( slPfx = fmt.Sprintf("sl:::%d:::", time.Now().UTC().UnixNano()) @@ -378,5 +380,5 @@ func flagFromEnvOrFile(envVars []string, filePath string) (value string, fromWhe } func flagSplitMultiValues(val string) []string { - return strings.Split(val, ",") + return strings.Split(val, defaultSliceFlagSeparator) } 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 000000000..64da59ea9 --- /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/godoc-current.txt b/vendor/github.com/urfave/cli/v2/godoc-current.txt index 80344eced..fadb7f862 100644 --- a/vendor/github.com/urfave/cli/v2/godoc-current.txt +++ b/vendor/github.com/urfave/cli/v2/godoc-current.txt @@ -316,6 +316,8 @@ 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 // Boolean to enable short-option handling so user can combine several // single-character bool arguments into one // i.e. foobar -o -v -> foobar -ov @@ -841,7 +843,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 diff --git a/vendor/github.com/urfave/cli/v2/help.go b/vendor/github.com/urfave/cli/v2/help.go index 466ff3479..6dc593b34 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 diff --git a/vendor/modules.txt b/vendor/modules.txt index 634905c7e..c8cfe1d3c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -332,7 +332,7 @@ github.com/rivo/uniseg # github.com/russross/blackfriday/v2 v2.1.0 ## explicit github.com/russross/blackfriday/v2 -# github.com/urfave/cli/v2 v2.20.3 +# github.com/urfave/cli/v2 v2.23.0 ## explicit; go 1.18 github.com/urfave/cli/v2 # github.com/valyala/bytebufferpool v1.0.0