diff --git a/go.mod b/go.mod index fce40f39f..f96b71300 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/sirupsen/logrus v1.9.4 github.com/stretchr/testify v1.11.1 github.com/urfave/cli-altsrc/v3 v3.1.0 - github.com/urfave/cli/v3 v3.6.2 + github.com/urfave/cli/v3 v3.7.0 golang.org/x/mod v0.33.0 golang.org/x/sys v0.41.0 tags.cncf.io/container-device-interface v1.1.0 diff --git a/go.sum b/go.sum index a75998c2f..a6cbf9464 100644 --- a/go.sum +++ b/go.sum @@ -82,8 +82,8 @@ github.com/tetratelabs/wazero v1.10.1 h1:2DugeJf6VVk58KTPszlNfeeN8AhhpwcZqkJj2ww github.com/tetratelabs/wazero v1.10.1/go.mod h1:DRm5twOQ5Gr1AoEdSi0CLjDQF1J9ZAuyqFIjl1KKfQU= github.com/urfave/cli-altsrc/v3 v3.1.0 h1:6E5+kXeAWmRxXlPgdEVf9VqVoTJ2MJci0UMpUi/w/bA= github.com/urfave/cli-altsrc/v3 v3.1.0/go.mod h1:VcWVTGXcL3nrXUDJZagHAeUX702La3PKeWav7KpISqA= -github.com/urfave/cli/v3 v3.6.2 h1:lQuqiPrZ1cIz8hz+HcrG0TNZFxU70dPZ3Yl+pSrH9A8= -github.com/urfave/cli/v3 v3.6.2/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= +github.com/urfave/cli/v3 v3.7.0 h1:AGSnbUyjtLiM+WJUb4dzXKldl/gL+F8OwmRDtVr6g2U= +github.com/urfave/cli/v3 v3.7.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= diff --git a/vendor/github.com/urfave/cli/v3/autocomplete/fish_autocomplete b/vendor/github.com/urfave/cli/v3/autocomplete/fish_autocomplete new file mode 100644 index 000000000..7aa7d0a8b --- /dev/null +++ b/vendor/github.com/urfave/cli/v3/autocomplete/fish_autocomplete @@ -0,0 +1,35 @@ +# This is a shell completion script auto-generated by https://github.com/urfave/cli for fish. + +function __%[1]_perform_completion + # Extract all args except the last one + set -l args (commandline -opc) + # Extract the last arg (partial input) + set -l lastArg (commandline -ct) + + set -l results ($args[1] $args[2..-1] $lastArg --generate-shell-completion 2> /dev/null) + + # Remove trailing empty lines + for line in $results[-1..1] + if test (string trim -- $line) = "" + set results $results[1..-2] + else + break + end + end + + for line in $results + if not string match -q -- "%[1]*" $line + set -l parts (string split -m 1 ":" -- "$line") + if test (count $parts) -eq 2 + printf "%s\t%s\n" "$parts[1]" "$parts[2]" + else + printf "%s\n" "$line" + end + end + end +end + +# Clear existing completions for %[1] +complete -c %[1] -e +# Register completion function +complete -c %[1] -f -a '(__%[1]_perform_completion)' \ No newline at end of file diff --git a/vendor/github.com/urfave/cli/v3/command_parse.go b/vendor/github.com/urfave/cli/v3/command_parse.go index aa95ae167..f8103d12f 100644 --- a/vendor/github.com/urfave/cli/v3/command_parse.go +++ b/vendor/github.com/urfave/cli/v3/command_parse.go @@ -36,7 +36,7 @@ func (cmd *Command) parseFlags(args Args) (Args, error) { pCmd.Name, cmd.Name, ) - for _, fl := range pCmd.Flags { + for _, fl := range pCmd.allFlags() { flNames := fl.Names() pfl, ok := fl.(LocalFlag) @@ -207,6 +207,7 @@ func (cmd *Command) parseFlags(args Args) (Args, error) { return &stringSliceArgs{posArgs}, fmt.Errorf("%s%s", argumentNotProvidedErrMsg, string(c)) } flagVal = rargs[1] + rargs = rargs[1:] } tracef("parseFlags (flagName %[1]q) (flagVal %[2]q)", flagName, flagVal) if err := cmd.set(flagName, sf, flagVal); err != nil { diff --git a/vendor/github.com/urfave/cli/v3/completion.go b/vendor/github.com/urfave/cli/v3/completion.go index 609b20437..de11edb40 100644 --- a/vendor/github.com/urfave/cli/v3/completion.go +++ b/vendor/github.com/urfave/cli/v3/completion.go @@ -31,7 +31,8 @@ var ( return fmt.Sprintf(string(b), appName), err }, "fish": func(c *Command, appName string) (string, error) { - return c.Root().ToFishCompletion() + b, err := autoCompleteFS.ReadFile("autocomplete/fish_autocomplete") + return fmt.Sprintf(string(b), appName), err }, "pwsh": func(c *Command, appName string) (string, error) { b, err := autoCompleteFS.ReadFile("autocomplete/powershell_autocomplete.ps1") diff --git a/vendor/github.com/urfave/cli/v3/fish.go b/vendor/github.com/urfave/cli/v3/fish.go index 1607f55b1..8002a33ca 100644 --- a/vendor/github.com/urfave/cli/v3/fish.go +++ b/vendor/github.com/urfave/cli/v3/fish.go @@ -34,6 +34,18 @@ func (cmd *Command) writeFishCompletionTemplate(w io.Writer) error { // Add global flags completions := prepareFishFlags(cmd.Name, cmd) + if cmd.ShellComplete != nil { + var completion strings.Builder + fmt.Fprintf(&completion, + "complete -c %s -n '%s' -xa '(%s %s 2>/dev/null)'", + cmd.Name, + fishFlagHelper(cmd.Name, cmd), + cmd.Name, + completionFlag, + ) + completions = append(completions, completion.String()) + } + // Add commands and their flags completions = append( completions, @@ -72,6 +84,26 @@ func prepareFishCommands(binary string, parent *Command) []string { } completions = append(completions, completion.String()) } + + if command.ShellComplete != nil { + var completion strings.Builder + var path []string + lineage := command.Lineage() + for i := len(lineage) - 2; i >= 0; i-- { + path = append(path, lineage[i].Name) + } + + fmt.Fprintf(&completion, + "complete -c %s -n '%s' -xa '(%s %s %s 2>/dev/null)'", + binary, + fishFlagHelper(binary, command), + binary, + strings.Join(path, " "), + completionFlag, + ) + completions = append(completions, completion.String()) + } + completions = append( completions, prepareFishFlags(binary, command)..., diff --git a/vendor/github.com/urfave/cli/v3/flag_duration.go b/vendor/github.com/urfave/cli/v3/flag_duration.go index e14ff428f..634789d16 100644 --- a/vendor/github.com/urfave/cli/v3/flag_duration.go +++ b/vendor/github.com/urfave/cli/v3/flag_duration.go @@ -45,6 +45,6 @@ func (cmd *Command) Duration(name string) time.Duration { return v } - tracef("bool NOT available for flag name %[1]q (cmd=%[2]q)", name, cmd.Name) + tracef("duration NOT available for flag name %[1]q (cmd=%[2]q)", name, cmd.Name) return 0 } diff --git a/vendor/github.com/urfave/cli/v3/help.go b/vendor/github.com/urfave/cli/v3/help.go index 37b109112..9db9df510 100644 --- a/vendor/github.com/urfave/cli/v3/help.go +++ b/vendor/github.com/urfave/cli/v3/help.go @@ -124,8 +124,7 @@ func helpCommandAction(ctx context.Context, cmd *Command) error { } // Case 3, 5 - if (len(cmd.Commands) == 1 && !cmd.HideHelp) || - (len(cmd.Commands) == 0 && cmd.HideHelp) { + if len(cmd.VisibleCommands()) == 0 { tmpl := cmd.CustomHelpTemplate if tmpl == "" { @@ -184,11 +183,12 @@ func DefaultRootCommandComplete(ctx context.Context, cmd *Command) { var DefaultAppComplete = DefaultRootCommandComplete func printCommandSuggestions(commands []*Command, writer io.Writer) { + shell := os.Getenv("SHELL") for _, command := range commands { if command.Hidden { continue } - if strings.HasSuffix(os.Getenv("SHELL"), "zsh") && len(command.Usage) > 0 { + if (strings.HasSuffix(shell, "zsh") || strings.HasSuffix(shell, "fish")) && len(command.Usage) > 0 { _, _ = fmt.Fprintf(writer, "%s:%s\n", command.Name, command.Usage) } else { _, _ = fmt.Fprintf(writer, "%s\n", command.Name) @@ -240,7 +240,8 @@ func printFlagSuggestions(lastArg string, flags []Flag, writer io.Writer) { // match if last argument matches this flag and it is not repeated if strings.HasPrefix(name, cur) && cur != name /* && !cliArgContains(name, os.Args)*/ { flagCompletion := fmt.Sprintf("%s%s", strings.Repeat("-", count), name) - if usage != "" && strings.HasSuffix(os.Getenv("SHELL"), "zsh") { + shell := os.Getenv("SHELL") + if usage != "" && (strings.HasSuffix(shell, "zsh") || strings.HasSuffix(shell, "fish")) { flagCompletion = fmt.Sprintf("%s:%s", flagCompletion, usage) } fmt.Fprintln(writer, flagCompletion) diff --git a/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt b/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt index 3f4ed158c..e41a984db 100644 --- a/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt +++ b/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt @@ -1,4 +1,4 @@ -mkdocs-git-revision-date-localized-plugin==1.5.0 +mkdocs-git-revision-date-localized-plugin==1.5.1 mkdocs-material==9.7.1 mkdocs==1.6.1 mkdocs-redirects==1.2.2 diff --git a/vendor/modules.txt b/vendor/modules.txt index 6aaf526f1..2c8802770 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -162,7 +162,7 @@ github.com/tetratelabs/wazero/sys # github.com/urfave/cli-altsrc/v3 v3.1.0 ## explicit; go 1.23.2 github.com/urfave/cli-altsrc/v3 -# github.com/urfave/cli/v3 v3.6.2 +# github.com/urfave/cli/v3 v3.7.0 ## explicit; go 1.22 github.com/urfave/cli/v3 # github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb