mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-08 06:22:55 +00:00
fix: mark plugin command groups in root help
This commit is contained in:
@@ -43,7 +43,16 @@ const EXAMPLES = [
|
||||
],
|
||||
] as const;
|
||||
|
||||
export function configureProgramHelp(program: Command, ctx: ProgramContext) {
|
||||
export function configureProgramHelp(
|
||||
program: Command,
|
||||
ctx: ProgramContext,
|
||||
options?: { commandsWithSubcommands?: ReadonlySet<string> },
|
||||
) {
|
||||
const commandsWithSubcommands = new Set([
|
||||
...ROOT_COMMANDS_WITH_SUBCOMMANDS,
|
||||
...(options?.commandsWithSubcommands ?? []),
|
||||
]);
|
||||
|
||||
program
|
||||
.name(CLI_NAME)
|
||||
.description("")
|
||||
@@ -77,7 +86,7 @@ export function configureProgramHelp(program: Command, ctx: ProgramContext) {
|
||||
optionTerm: (option) => theme.option(option.flags),
|
||||
subcommandTerm: (cmd) => {
|
||||
const isRootCommand = cmd.parent === program;
|
||||
const hasSubcommands = isRootCommand && ROOT_COMMANDS_WITH_SUBCOMMANDS.has(cmd.name());
|
||||
const hasSubcommands = isRootCommand && commandsWithSubcommands.has(cmd.name());
|
||||
return theme.command(hasSubcommands ? `${cmd.name()} *` : cmd.name());
|
||||
},
|
||||
});
|
||||
|
||||
@@ -80,6 +80,7 @@ describe("root help", () => {
|
||||
expect(text).toContain("status");
|
||||
expect(text).toContain("config");
|
||||
expect(text).toContain("matrix");
|
||||
expect(text).toContain("matrix *");
|
||||
expect(text).toContain("Matrix channel utilities");
|
||||
});
|
||||
|
||||
|
||||
@@ -19,19 +19,28 @@ export type RootHelpRenderOptions = Pick<PluginLoadOptions, "pluginSdkResolution
|
||||
|
||||
async function buildRootHelpProgram(renderOptions?: RootHelpRenderOptions): Promise<Command> {
|
||||
const program = new Command();
|
||||
configureProgramHelp(program, {
|
||||
programVersion: VERSION,
|
||||
channelOptions: [],
|
||||
messageChannelOptions: "",
|
||||
agentChannelOptions: "",
|
||||
});
|
||||
|
||||
const pluginDescriptors =
|
||||
renderOptions?.includePluginDescriptors === true || renderOptions?.config
|
||||
? await getPluginCliCommandDescriptors(renderOptions.config, renderOptions.env, {
|
||||
pluginSdkResolution: renderOptions.pluginSdkResolution,
|
||||
})
|
||||
: [];
|
||||
configureProgramHelp(
|
||||
program,
|
||||
{
|
||||
programVersion: VERSION,
|
||||
channelOptions: [],
|
||||
messageChannelOptions: "",
|
||||
agentChannelOptions: "",
|
||||
},
|
||||
{
|
||||
commandsWithSubcommands: new Set(
|
||||
pluginDescriptors
|
||||
.filter((descriptor) => descriptor.hasSubcommands)
|
||||
.map((descriptor) => descriptor.name),
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
addCommandDescriptorsToProgram(
|
||||
program,
|
||||
|
||||
Reference in New Issue
Block a user