Merge pull request #6571 from owncloud/dependabot/go_modules/github.com/urfave/cli/v2-2.25.7

Bump github.com/urfave/cli/v2 from 2.25.1 to 2.25.7
This commit is contained in:
Michael Barz
2023-06-23 16:08:13 +02:00
committed by GitHub
14 changed files with 81 additions and 47 deletions

2
go.mod
View File

@@ -76,7 +76,7 @@ require (
github.com/test-go/testify v1.1.4
github.com/thejerf/suture/v4 v4.0.2
github.com/tus/tusd v1.10.1
github.com/urfave/cli/v2 v2.25.1
github.com/urfave/cli/v2 v2.25.7
github.com/xhit/go-simple-mail/v2 v2.13.0
go-micro.dev/v4 v4.9.0
go.etcd.io/bbolt v1.3.7

4
go.sum
View File

@@ -1595,8 +1595,8 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqri
github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex1PFV8g=
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=

View File

@@ -332,11 +332,18 @@ func (a *App) RunContext(ctx context.Context, arguments []string) (err error) {
return a.rootCommand.Run(cCtx, arguments...)
}
// This is a stub function to keep public API unchanged from old code
//
// Deprecated: use App.Run or App.RunContext
// RunAsSubcommand is for legacy/compatibility purposes only. New code should only
// use App.RunContext. This function is slated to be removed in v3.
func (a *App) RunAsSubcommand(ctx *Context) (err error) {
return a.RunContext(ctx.Context, ctx.Args().Slice())
a.Setup()
cCtx := NewContext(a, nil, ctx)
cCtx.shellComplete = ctx.shellComplete
a.rootCommand = a.newRootCommand()
cCtx.Command = a.rootCommand
return a.rootCommand.Run(cCtx, ctx.Args().Slice()...)
}
func (a *App) suggestFlagFromError(err error, command string) (string, error) {

View File

@@ -56,6 +56,7 @@ func (cCtx *Context) Set(name, value string) error {
// IsSet determines if the flag was actually set
func (cCtx *Context) IsSet(name string) bool {
if fs := cCtx.lookupFlagSet(name); fs != nil {
isSet := false
fs.Visit(func(f *flag.Flag) {
@@ -72,7 +73,23 @@ func (cCtx *Context) IsSet(name string) bool {
return false
}
return f.IsSet()
if f.IsSet() {
return true
}
// now redo flagset search on aliases
aliases := f.Names()
fs.Visit(func(f *flag.Flag) {
for _, alias := range aliases {
if f.Name == alias {
isSet = true
}
}
})
if isSet {
return true
}
}
return false
@@ -204,9 +221,10 @@ func (cCtx *Context) checkRequiredFlags(flags []Flag) requiredFlagsErr {
var flagPresent bool
var flagName string
for _, key := range f.Names() {
flagName = key
flagNames := f.Names()
flagName = flagNames[0]
for _, key := range flagNames {
if cCtx.IsSet(strings.TrimSpace(key)) {
flagPresent = true
}

View File

@@ -153,9 +153,14 @@ func prepareFlags(
// flagDetails returns a string containing the flags metadata
func flagDetails(flag DocGenerationFlag) string {
description := flag.GetUsage()
value := flag.GetValue()
if value != "" {
description += " (default: " + value + ")"
if flag.TakesValue() {
defaultText := flag.GetDefaultText()
if defaultText == "" {
defaultText = flag.GetValue()
}
if defaultText != "" {
description += " (default: " + defaultText + ")"
}
}
return ": " + description
}

View File

@@ -52,7 +52,7 @@ func (b *boolValue) String() string {
func (b *boolValue) IsBoolFlag() bool { return true }
func (b *boolValue) Count() int {
if b.count != nil {
if b.count != nil && *b.count > 0 {
return *b.count
}
return 0
@@ -130,6 +130,11 @@ func (f *BoolFlag) Apply(set *flag.FlagSet) error {
if count == nil {
count = new(int)
}
// since count will be incremented for each alias as well
// subtract number of aliases from overall count
*count -= len(f.Aliases)
if dest == nil {
dest = new(bool)
}

View File

@@ -117,13 +117,8 @@ func (cCtx *Context) Generic(name string) interface{} {
}
func lookupGeneric(name string, set *flag.FlagSet) interface{} {
f := set.Lookup(name)
if f != nil {
parsed, err := f.Value, error(nil)
if err != nil {
return nil
}
return parsed
if f := set.Lookup(name); f != nil {
return f.Value
}
return nil
}

View File

@@ -90,13 +90,8 @@ func (cCtx *Context) Path(name string) string {
}
func lookupPath(name string, set *flag.FlagSet) string {
f := set.Lookup(name)
if f != nil {
parsed, err := f.Value.String(), error(nil)
if err != nil {
return ""
}
return parsed
if f := set.Lookup(name); f != nil {
return f.Value.String()
}
return ""
}

View File

@@ -87,10 +87,8 @@ func (cCtx *Context) String(name string) string {
}
func lookupString(name string, set *flag.FlagSet) string {
f := set.Lookup(name)
if f != nil {
parsed := f.Value.String()
return parsed
if f := set.Lookup(name); f != nil {
return f.Value.String()
}
return ""
}

View File

@@ -145,11 +145,6 @@ func (f *TimestampFlag) Apply(set *flag.FlagSet) error {
f.defaultValue = f.Value.clone()
if f.Destination != nil {
f.Destination.SetLayout(f.Layout)
f.Destination.SetLocation(f.Timezone)
}
if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found {
if err := f.Value.Set(val); err != nil {
return fmt.Errorf("could not parse %q as timestamp value from %s for flag %s: %s", val, source, f.Name, err)
@@ -157,6 +152,10 @@ func (f *TimestampFlag) Apply(set *flag.FlagSet) error {
f.HasBeenSet = true
}
if f.Destination != nil {
*f.Destination = *f.Value
}
for _, name := range f.Names() {
if f.Destination != nil {
set.Var(f.Destination, name, f.Usage)

View File

@@ -141,7 +141,7 @@ USAGE:
DESCRIPTION:
{{template "descriptionTemplate" .}}{{end}}{{if .VisibleCommands}}
COMMANDS:{{template "visibleCommandTemplate" .}}{{end}}{{if .VisibleFlagCategories}}
COMMANDS:{{template "visibleCommandCategoryTemplate" .}}{{end}}{{if .VisibleFlagCategories}}
OPTIONS:{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}}
@@ -357,9 +357,8 @@ func (a *App) RunAndExitOnError()
code in the cli.ExitCoder
func (a *App) RunAsSubcommand(ctx *Context) (err error)
This is a stub function to keep public API unchanged from old code
Deprecated: use App.Run or App.RunContext
RunAsSubcommand is for legacy/compatibility purposes only. New code should
only use App.RunContext. This function is slated to be removed in v3.
func (a *App) RunContext(ctx context.Context, arguments []string) (err error)
RunContext is like Run except it takes a Context that will be passed to

View File

@@ -42,6 +42,7 @@ var helpCommand = &Command{
// 3 $ app foo
// 4 $ app help foo
// 5 $ app foo help
// 6 $ app foo -h (with no other sub-commands nor flags defined)
// Case 4. when executing a help command set the context to parent
// to allow resolution of subsequent args. This will transform
@@ -77,6 +78,8 @@ var helpCommand = &Command{
HelpPrinter(cCtx.App.Writer, templ, cCtx.Command)
return nil
}
// Case 6, handling incorporated in the callee itself
return ShowSubcommandHelp(cCtx)
},
}
@@ -206,9 +209,15 @@ func printFlagSuggestions(lastArg string, flags []Flag, writer io.Writer) {
func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context) {
return func(cCtx *Context) {
if len(os.Args) > 2 {
lastArg := os.Args[len(os.Args)-2]
var lastArg string
// TODO: This shouldnt depend on os.Args rather it should
// depend on root arguments passed to App
if len(os.Args) > 2 {
lastArg = os.Args[len(os.Args)-2]
}
if lastArg != "" {
if strings.HasPrefix(lastArg, "-") {
if cmd != nil {
printFlagSuggestions(lastArg, cmd.Flags, cCtx.App.Writer)
@@ -292,8 +301,12 @@ func ShowSubcommandHelp(cCtx *Context) error {
if cCtx == nil {
return nil
}
HelpPrinter(cCtx.App.Writer, SubcommandHelpTemplate, cCtx.Command)
// use custom template when provided (fixes #1703)
templ := SubcommandHelpTemplate
if cCtx.Command != nil && cCtx.Command.CustomHelpTemplate != "" {
templ = cCtx.Command.CustomHelpTemplate
}
HelpPrinter(cCtx.App.Writer, templ, cCtx.Command)
return nil
}

View File

@@ -88,7 +88,7 @@ USAGE:
DESCRIPTION:
{{template "descriptionTemplate" .}}{{end}}{{if .VisibleCommands}}
COMMANDS:{{template "visibleCommandTemplate" .}}{{end}}{{if .VisibleFlagCategories}}
COMMANDS:{{template "visibleCommandCategoryTemplate" .}}{{end}}{{if .VisibleFlagCategories}}
OPTIONS:{{template "visibleFlagCategoryTemplate" .}}{{else if .VisibleFlags}}

2
vendor/modules.txt vendored
View File

@@ -1665,7 +1665,7 @@ github.com/trustelem/zxcvbn/scoring
# github.com/tus/tusd v1.10.1
## explicit; go 1.16
github.com/tus/tusd/pkg/handler
# github.com/urfave/cli/v2 v2.25.1
# github.com/urfave/cli/v2 v2.25.7
## explicit; go 1.18
github.com/urfave/cli/v2
# github.com/wk8/go-ordered-map v1.0.0