diff options
author | 2024-06-17 08:13:40 +0000 | |
---|---|---|
committer | 2024-06-17 08:13:40 +0000 | |
commit | 7ab404d64335dc0b6977e9fb38140ad6fc5b91b7 (patch) | |
tree | 5c589e9a69f90ad6bc50036f5632758f1e5bf3ac /vendor/github.com/spf13/cobra/bash_completions.go | |
parent | [chore]: Bump golang.org/x/oauth2 from 0.20.0 to 0.21.0 (#3015) (diff) | |
download | gotosocial-7ab404d64335dc0b6977e9fb38140ad6fc5b91b7.tar.xz |
[chore]: Bump github.com/spf13/cobra from 1.8.0 to 1.8.1 (#3016)
Diffstat (limited to 'vendor/github.com/spf13/cobra/bash_completions.go')
-rw-r--r-- | vendor/github.com/spf13/cobra/bash_completions.go | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/vendor/github.com/spf13/cobra/bash_completions.go b/vendor/github.com/spf13/cobra/bash_completions.go index 8a5315184..f4d198cbc 100644 --- a/vendor/github.com/spf13/cobra/bash_completions.go +++ b/vendor/github.com/spf13/cobra/bash_completions.go @@ -597,19 +597,16 @@ func writeRequiredFlag(buf io.StringWriter, cmd *Command) { if nonCompletableFlag(flag) { return } - for key := range flag.Annotations { - switch key { - case BashCompOneRequiredFlag: - format := " must_have_one_flag+=(\"--%s" - if flag.Value.Type() != "bool" { - format += "=" - } - format += cbn - WriteStringAndCheck(buf, fmt.Sprintf(format, flag.Name)) - - if len(flag.Shorthand) > 0 { - WriteStringAndCheck(buf, fmt.Sprintf(" must_have_one_flag+=(\"-%s"+cbn, flag.Shorthand)) - } + if _, ok := flag.Annotations[BashCompOneRequiredFlag]; ok { + format := " must_have_one_flag+=(\"--%s" + if flag.Value.Type() != "bool" { + format += "=" + } + format += cbn + WriteStringAndCheck(buf, fmt.Sprintf(format, flag.Name)) + + if len(flag.Shorthand) > 0 { + WriteStringAndCheck(buf, fmt.Sprintf(" must_have_one_flag+=(\"-%s"+cbn, flag.Shorthand)) } } }) @@ -621,7 +618,7 @@ func writeRequiredNouns(buf io.StringWriter, cmd *Command) { for _, value := range cmd.ValidArgs { // Remove any description that may be included following a tab character. // Descriptions are not supported by bash completion. - value = strings.Split(value, "\t")[0] + value = strings.SplitN(value, "\t", 2)[0] WriteStringAndCheck(buf, fmt.Sprintf(" must_have_one_noun+=(%q)\n", value)) } if cmd.ValidArgsFunction != nil { |