vendor: update github.com/urfave/cli/v2 from 2.20.3 to 2.23.0

This commit is contained in:
Aliaksandr Valialkin 2022-11-01 10:46:03 +02:00
parent a1a97b9321
commit a3dc324b19
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
11 changed files with 97 additions and 14 deletions

2
go.mod
View file

@ -23,7 +23,7 @@ require (
github.com/influxdata/influxdb v1.10.0 github.com/influxdata/influxdb v1.10.0
github.com/klauspost/compress v1.15.12 github.com/klauspost/compress v1.15.12
github.com/prometheus/prometheus v1.8.2-0.20201119142752-3ad25a6dc3d9 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/fastjson v1.6.3
github.com/valyala/fastrand v1.1.0 github.com/valyala/fastrand v1.1.0
github.com/valyala/fasttemplate v1.2.2 github.com/valyala/fasttemplate v1.2.2

4
go.sum
View file

@ -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/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.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= 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.23.0 h1:pkly7gKIeYv3olPAeNajNpLjeJrmTPYCoZWaV+2VfvE=
github.com/urfave/cli/v2 v2.20.3/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= 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 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.30.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus= github.com/valyala/fasthttp v1.30.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus=

View file

@ -8,6 +8,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
"strings"
"time" "time"
) )
@ -20,6 +21,7 @@ var (
errInvalidActionType = NewExitError("ERROR invalid Action type. "+ errInvalidActionType = NewExitError("ERROR invalid Action type. "+
fmt.Sprintf("Must be `func(*Context`)` or `func(*Context) error). %s", contactSysadmin)+ fmt.Sprintf("Must be `func(*Context`)` or `func(*Context) error). %s", contactSysadmin)+
fmt.Sprintf("See %s", appActionDeprecationURL), 2) fmt.Sprintf("See %s", appActionDeprecationURL), 2)
ignoreFlagPrefix = "test." // this is to ignore test flags when adding flags from other packages
SuggestFlag SuggestFlagFunc = suggestFlag SuggestFlag SuggestFlagFunc = suggestFlag
SuggestCommand SuggestCommandFunc = suggestCommand SuggestCommand SuggestCommandFunc = suggestCommand
@ -103,6 +105,8 @@ type App struct {
// cli.go uses text/template to render templates. You can // cli.go uses text/template to render templates. You can
// render custom help text by setting this variable. // render custom help text by setting this variable.
CustomAppHelpTemplate string 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 // Boolean to enable short-option handling so user can combine several
// single-character bool arguments into one // single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov // i.e. foobar -o -v -> foobar -ov
@ -195,6 +199,14 @@ func (a *App) Setup() {
a.ErrWriter = os.Stderr 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 var newCommands []*Command
for _, c := range a.Commands { for _, c := range a.Commands {
@ -241,6 +253,10 @@ func (a *App) Setup() {
if a.Metadata == nil { if a.Metadata == nil {
a.Metadata = make(map[string]interface{}) a.Metadata = make(map[string]interface{})
} }
if len(a.SliceFlagSeparator) != 0 {
defaultSliceFlagSeparator = a.SliceFlagSeparator
}
} }
func (a *App) newRootCommand() *Command { func (a *App) newRootCommand() *Command {

View file

@ -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 { if dc := cCtx.App.Command(cCtx.App.DefaultCommand); dc != c {
cmd = dc cmd = dc
} }

View file

@ -83,7 +83,7 @@ type ExitCoder interface {
type exitError struct { type exitError struct {
exitCode int exitCode int
message interface{} err error
} }
// NewExitError calls Exit to create a new ExitCoder. // 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 // 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 // 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. // OsExiter function.
func Exit(message interface{}, exitCode int) ExitCoder { 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{ return &exitError{
message: message, err: err,
exitCode: exitCode, exitCode: exitCode,
} }
} }
func (ee *exitError) Error() string { func (ee *exitError) Error() string {
return fmt.Sprintf("%v", ee.message) return ee.err.Error()
} }
func (ee *exitError) ExitCode() int { func (ee *exitError) ExitCode() int {
return ee.exitCode return ee.exitCode
} }
func (ee *exitError) Unwrap() error {
return ee.err
}
// HandleExitCoder handles errors implementing ExitCoder by printing their // HandleExitCoder handles errors implementing ExitCoder by printing their
// message and calling OsExiter with the given exit code. // message and calling OsExiter with the given exit code.
// //

View file

@ -98,7 +98,7 @@ func (a *App) prepareFishCommands(commands []*Command, allCommands *[]string, pr
a.prepareFishFlags(command.VisibleFlags(), command.Names())..., a.prepareFishFlags(command.VisibleFlags(), command.Names())...,
) )
// recursevly iterate subcommands // recursively iterate subcommands
if len(command.Subcommands) > 0 { if len(command.Subcommands) > 0 {
completions = append( completions = append(
completions, completions,

View file

@ -15,6 +15,8 @@ import (
const defaultPlaceholder = "value" const defaultPlaceholder = "value"
var defaultSliceFlagSeparator = ","
var ( var (
slPfx = fmt.Sprintf("sl:::%d:::", time.Now().UTC().UnixNano()) 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 { func flagSplitMultiValues(val string) []string {
return strings.Split(val, ",") return strings.Split(val, defaultSliceFlagSeparator)
} }

48
vendor/github.com/urfave/cli/v2/flag_ext.go generated vendored Normal file
View file

@ -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
}

View file

@ -316,6 +316,8 @@ type App struct {
// cli.go uses text/template to render templates. You can // cli.go uses text/template to render templates. You can
// render custom help text by setting this variable. // render custom help text by setting this variable.
CustomAppHelpTemplate string 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 // Boolean to enable short-option handling so user can combine several
// single-character bool arguments into one // single-character bool arguments into one
// i.e. foobar -o -v -> foobar -ov // 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 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 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. package-global OsExiter function.
func NewExitError(message interface{}, exitCode int) ExitCoder func NewExitError(message interface{}, exitCode int) ExitCoder

View file

@ -60,7 +60,7 @@ var helpCommand = &Command{
} }
// Case 1 & 2 // 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 // commands/subcommands
if cCtx.parentContext.App == nil { if cCtx.parentContext.App == nil {
_ = ShowAppHelp(cCtx) _ = 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 // this will get total count utf8 letters in flag name
count := utf8.RuneCountInString(name) count := utf8.RuneCountInString(name)
if count > 2 { 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 // 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 // skip flag completion for short flags example -v or -x

2
vendor/modules.txt vendored
View file

@ -332,7 +332,7 @@ github.com/rivo/uniseg
# github.com/russross/blackfriday/v2 v2.1.0 # github.com/russross/blackfriday/v2 v2.1.0
## explicit ## explicit
github.com/russross/blackfriday/v2 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 ## explicit; go 1.18
github.com/urfave/cli/v2 github.com/urfave/cli/v2
# github.com/valyala/bytebufferpool v1.0.0 # github.com/valyala/bytebufferpool v1.0.0