Commit fd270da6d7
Verified · cmc
Layout: unified · split
internal/control/help.go +13 −5
| @@ -330,10 +330,16 @@ func (c *Ctx) helpVerb(w io.Writer, cmd Command, below []Command) { | |||
| 330 | func (c *Ctx) helpNoun(w io.Writer, prefix string, cmds []Command, override map[string]string) { | 330 | func (c *Ctx) helpNoun(w io.Writer, prefix string, cmds []Command, override map[string]string) { |
| 331 | head := nounSummaries[strings.Fields(prefix)[0]] | 331 | head := nounSummaries[strings.Fields(prefix)[0]] |
| 332 | fmt.Fprintln(w, head) | 332 | fmt.Fprintln(w, head) |
| 333 | fmt.Fprintln(w) | 333 | // An aliased noun is a CLI grouping: over stock ssh there is no |
| 334 | c.heading(w, "USAGE") | 334 | // "auth <verb>" to type, and each row already names its full command. |
| 335 | _, aliased := nounAliases[prefix] | ||
| 336 | bare := aliased && c.CLIPath == "" | ||
| 335 | display := c.shownAs(prefix, prefix) | 337 | display := c.shownAs(prefix, prefix) |
| 336 | fmt.Fprintf(w, " %s %s <verb> ...\n", c.program(), display) | 338 | if !bare { |
| 339 | fmt.Fprintln(w) | ||
| 340 | c.heading(w, "USAGE") | ||
| 341 | fmt.Fprintf(w, " %s %s <verb> ...\n", c.program(), display) | ||
| 342 | } | ||
| 337 | rowText := func(cmd Command) string { | 343 | rowText := func(cmd Command) string { |
| 338 | full := joinPath(cmd.Path) | 344 | full := joinPath(cmd.Path) |
| 339 | if ov, ok := override[full]; ok { | 345 | if ov, ok := override[full]; ok { |
| @@ -362,6 +368,8 @@ func (c *Ctx) helpNoun(w io.Writer, prefix string, cmds []Command, override map[ | |||
| 362 | fmt.Fprintf(w, " %s %s\n", pad(rowText(cmd), wide), cmd.Summary) | 368 | fmt.Fprintf(w, " %s %s\n", pad(rowText(cmd), wide), cmd.Summary) |
| 363 | } | 369 | } |
| 364 | } | 370 | } |
| 365 | fmt.Fprintln(w) | 371 | if !bare { |
| 366 | fmt.Fprintf(w, "%s %s <verb> --help for flags.\n", c.program(), display) | 372 | fmt.Fprintln(w) |
| 373 | fmt.Fprintf(w, "%s %s <verb> --help for flags.\n", c.program(), display) | ||
| 374 | } | ||
| 367 | } | 375 | } |
internal/control/help_test.go +3
| @@ -270,4 +270,7 @@ func TestHelpRendersAnAliasedNounInRegisteredFormOverSSH(t *testing.T) { | |||
| 270 | if strings.Contains(got, "auth keys list") { | 270 | if strings.Contains(got, "auth keys list") { |
| 271 | t.Errorf("stock ssh should not see the CLI-only auth prefix: %s", got) | 271 | t.Errorf("stock ssh should not see the CLI-only auth prefix: %s", got) |
| 272 | } | 272 | } |
| 273 | if strings.Contains(got, " auth <verb>") { | ||
| 274 | t.Errorf("stock ssh should not be told to type auth <verb>, which the server has no command for: %s", got) | ||
| 275 | } | ||
| 273 | } | 276 | } |