Skip to content

Commit bc16820

Browse files
committed
fix: show usage hint for commands with single-word Use field
Carapace only populates Usage when cmd.Use has 2+ words. Fall back to cobra's UseLine() for the resolved target command so that commands like "tcp" still display usage hints below the input line.
1 parent c681285 commit bc16820

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

external/console/completer.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ func (c *Console) complete(line []rune, pos int) (comps readline.Completions) {
8888

8989
// Assign both completions and command/flags/args usage strings.
9090
comps = readline.CompleteRaw(raw)
91-
comps = comps.Usage("%s", completions.Usage)
91+
usage := completions.Usage
92+
if usage == "" {
93+
if target := findCompletionTarget(menu.Command, args[2:]); target != nil && target != menu.Command {
94+
usage = target.UseLine()
95+
}
96+
}
97+
comps = comps.Usage("%s", usage)
9298
comps = c.justifyCommandComps(comps)
9399

94100
// If any errors arose from the completion call itself.

0 commit comments

Comments
 (0)