From 07e5d89febb30bf8525a016f27d04dbbf663d8ae Mon Sep 17 00:00:00 2001 From: notgitika Date: Fri, 4 Sep 2026 01:45:56 -0400 Subject: [PATCH] chore(help): simplify command indexes --- src/router/router.test.ts | 29 +++++++++++++++++++++++++++++ src/router/router.tsx | 1 + 2 files changed, 30 insertions(+) diff --git a/src/router/router.test.ts b/src/router/router.test.ts index ced99b7d3..72f5329ad 100644 --- a/src/router/router.test.ts +++ b/src/router/router.test.ts @@ -706,6 +706,35 @@ test("command groups omit Commander's generated help subcommand", async () => { expect(out).not.toContain("help [command]"); }); +test("command indexes show names without usage syntax", async () => { + const withOptions = createHandler({ + name: "with-options", + description: "command with flags", + flags: [flag("format", "output format", z.string().optional())], + handle: async () => {}, + }); + const withArguments = createHandler({ + name: "with-arguments", + description: "command with arguments", + arguments: [ + argument("required", "required value", z.string()), + argument("optional", "optional value", z.string().optional()), + ], + handle: async () => {}, + }); + const nested = new Router("nested", "command group").handler(leaf("deep", () => {})); + const root = new Router("app").handler(withOptions).handler(withArguments).handler(nested); + + const out = await helpOutput(root, ["app", "--help"]); + + expect(out).toContain("Usage: app [options] [command]"); + expect(out).toContain("with-options"); + expect(out).not.toContain("with-options [options]"); + expect(out).toContain("with-arguments"); + expect(out).not.toContain("with-arguments [optional]"); + expect(out).not.toContain("nested [command]"); +}); + test("flags with long-form help render a Parameter details section", async () => { const create = createHandler({ name: "create", diff --git a/src/router/router.tsx b/src/router/router.tsx index 5b7f41e86..3573caa1f 100644 --- a/src/router/router.tsx +++ b/src/router/router.tsx @@ -166,6 +166,7 @@ export function compile( const compiledNode = withEffectiveTuiSupport(node, effectiveTuiSupport); const c = new RoutedCommand(compiledNode); c.addHelpCommand(false); + c.configureHelp({ subcommandTerm: (command) => command.name() }); c.description(node.description()); const ownFlags = node.flags();