fix: mark plugin command groups in root help · openclaw/openclaw@482018e
steipete
·
2026-05-27
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -43,7 +43,16 @@ const EXAMPLES = [
|
43 | 43 | ], |
44 | 44 | ] as const; |
45 | 45 | |
46 | | -export function configureProgramHelp(program: Command, ctx: ProgramContext) { |
| 46 | +export function configureProgramHelp( |
| 47 | +program: Command, |
| 48 | +ctx: ProgramContext, |
| 49 | +options?: { commandsWithSubcommands?: ReadonlySet<string> }, |
| 50 | +) { |
| 51 | +const commandsWithSubcommands = new Set([ |
| 52 | + ...ROOT_COMMANDS_WITH_SUBCOMMANDS, |
| 53 | + ...(options?.commandsWithSubcommands ?? []), |
| 54 | +]); |
| 55 | + |
47 | 56 | program |
48 | 57 | .name(CLI_NAME) |
49 | 58 | .description("") |
@@ -77,7 +86,7 @@ export function configureProgramHelp(program: Command, ctx: ProgramContext) {
|
77 | 86 | optionTerm: (option) => theme.option(option.flags), |
78 | 87 | subcommandTerm: (cmd) => { |
79 | 88 | const isRootCommand = cmd.parent === program; |
80 | | -const hasSubcommands = isRootCommand && ROOT_COMMANDS_WITH_SUBCOMMANDS.has(cmd.name()); |
| 89 | +const hasSubcommands = isRootCommand && commandsWithSubcommands.has(cmd.name()); |
81 | 90 | return theme.command(hasSubcommands ? `${cmd.name()} *` : cmd.name()); |
82 | 91 | }, |
83 | 92 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -80,6 +80,7 @@ describe("root help", () => {
|
80 | 80 | expect(text).toContain("status"); |
81 | 81 | expect(text).toContain("config"); |
82 | 82 | expect(text).toContain("matrix"); |
| 83 | +expect(text).toContain("matrix *"); |
83 | 84 | expect(text).toContain("Matrix channel utilities"); |
84 | 85 | }); |
85 | 86 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -19,19 +19,28 @@ export type RootHelpRenderOptions = Pick<PluginLoadOptions, "pluginSdkResolution
|
19 | 19 | |
20 | 20 | async function buildRootHelpProgram(renderOptions?: RootHelpRenderOptions): Promise<Command> { |
21 | 21 | const program = new Command(); |
22 | | -configureProgramHelp(program, { |
23 | | -programVersion: VERSION, |
24 | | -channelOptions: [], |
25 | | -messageChannelOptions: "", |
26 | | -agentChannelOptions: "", |
27 | | -}); |
28 | | - |
29 | 22 | const pluginDescriptors = |
30 | 23 | renderOptions?.includePluginDescriptors === true || renderOptions?.config |
31 | 24 | ? await getPluginCliCommandDescriptors(renderOptions.config, renderOptions.env, { |
32 | 25 | pluginSdkResolution: renderOptions.pluginSdkResolution, |
33 | 26 | }) |
34 | 27 | : []; |
| 28 | +configureProgramHelp( |
| 29 | +program, |
| 30 | +{ |
| 31 | +programVersion: VERSION, |
| 32 | +channelOptions: [], |
| 33 | +messageChannelOptions: "", |
| 34 | +agentChannelOptions: "", |
| 35 | +}, |
| 36 | +{ |
| 37 | +commandsWithSubcommands: new Set( |
| 38 | +pluginDescriptors |
| 39 | +.filter((descriptor) => descriptor.hasSubcommands) |
| 40 | +.map((descriptor) => descriptor.name), |
| 41 | +), |
| 42 | +}, |
| 43 | +); |
35 | 44 | |
36 | 45 | addCommandDescriptorsToProgram( |
37 | 46 | program, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。