mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-05 22:32:12 +00:00
CLI: keep root help plugin descriptors non-activating (#57294)
Merged via squash.
Prepared head SHA: c8da48f689
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
1efef8205c
commit
e5dac0c39e
@@ -23,7 +23,7 @@ vi.mock("./subcli-descriptors.js", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("../../plugins/cli.js", () => ({
|
||||
getPluginCliCommandDescriptors: () => [
|
||||
getPluginCliCommandDescriptors: async () => [
|
||||
{
|
||||
name: "matrix",
|
||||
description: "Matrix channel utilities",
|
||||
@@ -35,8 +35,8 @@ vi.mock("../../plugins/cli.js", () => ({
|
||||
const { renderRootHelpText } = await import("./root-help.js");
|
||||
|
||||
describe("root help", () => {
|
||||
it("includes plugin CLI descriptors alongside core and sub-CLI commands", () => {
|
||||
const text = renderRootHelpText();
|
||||
it("includes plugin CLI descriptors alongside core and sub-CLI commands", async () => {
|
||||
const text = await renderRootHelpText();
|
||||
|
||||
expect(text).toContain("status");
|
||||
expect(text).toContain("config");
|
||||
|
||||
@@ -5,7 +5,7 @@ import { getCoreCliCommandDescriptors } from "./core-command-descriptors.js";
|
||||
import { configureProgramHelp } from "./help.js";
|
||||
import { getSubCliEntries } from "./subcli-descriptors.js";
|
||||
|
||||
function buildRootHelpProgram(): Command {
|
||||
async function buildRootHelpProgram(): Promise<Command> {
|
||||
const program = new Command();
|
||||
configureProgramHelp(program, {
|
||||
programVersion: VERSION,
|
||||
@@ -26,7 +26,7 @@ function buildRootHelpProgram(): Command {
|
||||
program.command(command.name).description(command.description);
|
||||
existingCommands.add(command.name);
|
||||
}
|
||||
for (const command of getPluginCliCommandDescriptors()) {
|
||||
for (const command of await getPluginCliCommandDescriptors()) {
|
||||
if (existingCommands.has(command.name)) {
|
||||
continue;
|
||||
}
|
||||
@@ -37,8 +37,8 @@ function buildRootHelpProgram(): Command {
|
||||
return program;
|
||||
}
|
||||
|
||||
export function renderRootHelpText(): string {
|
||||
const program = buildRootHelpProgram();
|
||||
export async function renderRootHelpText(): Promise<string> {
|
||||
const program = await buildRootHelpProgram();
|
||||
let output = "";
|
||||
const originalWrite = process.stdout.write.bind(process.stdout);
|
||||
const captureWrite: typeof process.stdout.write = ((chunk: string | Uint8Array) => {
|
||||
@@ -54,6 +54,6 @@ export function renderRootHelpText(): string {
|
||||
return output;
|
||||
}
|
||||
|
||||
export function outputRootHelp(): void {
|
||||
process.stdout.write(renderRootHelpText());
|
||||
export async function outputRootHelp(): Promise<void> {
|
||||
process.stdout.write(await renderRootHelpText());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user