Show aliases beneath empty command groups
This commit is contained in:
@@ -214,6 +214,29 @@ func TestDiscoveryHelpThroughExpandedGroupPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyCanonicalGroupHelpListsAliasRoutes(t *testing.T) {
|
||||
app, err := New(Identity{Name: "Demo"}, Group("box", "Box"), Group("quiet", "Quiet"),
|
||||
simpleRunnable("inspect"), Alias("box pick", "inspect"), Alias("pk", "box"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, args := range [][]string{{"box", "--help"}, {"help", "box"}, {"pk", "--help"}, {"help", "pk"}} {
|
||||
var output bytes.Buffer
|
||||
outcome := app.Execute(context.Background(), args, Streams{Out: &output, Err: io.Discard})
|
||||
if outcome.Kind != OutcomeSuccess || !strings.Contains(output.String(), "pick → inspect") {
|
||||
t.Errorf("Execute(%q) = %v, help %q", args, outcome.Kind, output.String())
|
||||
}
|
||||
}
|
||||
var output bytes.Buffer
|
||||
outcome := app.Execute(context.Background(), []string{"quiet", "--help"}, Streams{Out: &output, Err: io.Discard})
|
||||
if outcome.Kind != OutcomeSuccess || strings.Contains(output.String(), "Command Aliases:") {
|
||||
t.Fatalf("unaliased group help = %v, %q", outcome.Kind, output.String())
|
||||
}
|
||||
if outcome := app.Execute(context.Background(), []string{"box", "pick"}, Streams{Out: io.Discard, Err: io.Discard}); outcome.Kind != OutcomeSuccess {
|
||||
t.Fatal("alias route became unavailable")
|
||||
}
|
||||
}
|
||||
|
||||
func routeTestApp(t *testing.T, extra ...Declaration) *App {
|
||||
t.Helper()
|
||||
collections := simpleRunnable("collections")
|
||||
|
||||
Reference in New Issue
Block a user