mirror of
https://github.com/spf13/cobra
synced 2025-04-27 17:17:20 +00:00
Use strings.Builder to construct suggestions
This commit is contained in:
parent
3c47a5a9c8
commit
4585aea30f
1 changed files with 4 additions and 4 deletions
|
@ -749,14 +749,14 @@ func (c *Command) findSuggestions(arg string) string {
|
||||||
if c.SuggestionsMinimumDistance <= 0 {
|
if c.SuggestionsMinimumDistance <= 0 {
|
||||||
c.SuggestionsMinimumDistance = 2
|
c.SuggestionsMinimumDistance = 2
|
||||||
}
|
}
|
||||||
suggestionsString := ""
|
var sb strings.Builder
|
||||||
if suggestions := c.SuggestionsFor(arg); len(suggestions) > 0 {
|
if suggestions := c.SuggestionsFor(arg); len(suggestions) > 0 {
|
||||||
suggestionsString += "\n\nDid you mean this?\n"
|
sb.WriteString("\n\nDid you mean this?\n")
|
||||||
for _, s := range suggestions {
|
for _, s := range suggestions {
|
||||||
suggestionsString += fmt.Sprintf("\t%v\n", s)
|
_, _ = fmt.Fprintf(&sb, "\t%v\n", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return suggestionsString
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Command) findNext(next string) *Command {
|
func (c *Command) findNext(next string) *Command {
|
||||||
|
|
Loading…
Add table
Reference in a new issue