mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:20:43 +00:00
fix(cli): restore help registration and descriptor graph
This commit is contained in:
@@ -14,11 +14,12 @@ export function shouldSkipPluginCommandRegistration(params: {
|
||||
if (params.hasBuiltinPrimary) {
|
||||
return true;
|
||||
}
|
||||
if (params.primary === "help" && resolveCliArgvInvocation(params.argv).hasHelpOrVersion) {
|
||||
return true;
|
||||
const invocation = resolveCliArgvInvocation(params.argv);
|
||||
if (params.primary === "help") {
|
||||
return invocation.hasHelpOrVersion && invocation.commandPath.length <= 1;
|
||||
}
|
||||
if (!params.primary) {
|
||||
return resolveCliArgvInvocation(params.argv).hasHelpOrVersion;
|
||||
return invocation.hasHelpOrVersion;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { Command } from "commander";
|
||||
import type { CommandGroupEntry } from "./register-command-groups.js";
|
||||
|
||||
export type NamedCommandDescriptor = {
|
||||
name: string;
|
||||
@@ -23,6 +22,11 @@ export type ResolvedCommandGroupEntry<TDescriptor extends NamedCommandDescriptor
|
||||
register: TRegister;
|
||||
};
|
||||
|
||||
type CommandGroupEntryLike = {
|
||||
placeholders: NamedCommandDescriptor[];
|
||||
register: (program: Command) => Promise<void> | void;
|
||||
};
|
||||
|
||||
function buildDescriptorIndex<TDescriptor extends NamedCommandDescriptor>(
|
||||
descriptors: readonly TDescriptor[],
|
||||
): Map<string, TDescriptor> {
|
||||
@@ -49,8 +53,8 @@ export function resolveCommandGroupEntries<TDescriptor extends NamedCommandDescr
|
||||
export function buildCommandGroupEntries<TRegister>(
|
||||
descriptors: readonly NamedCommandDescriptor[],
|
||||
specs: readonly CommandGroupDescriptorSpec<TRegister>[],
|
||||
mapRegister: (register: TRegister) => CommandGroupEntry["register"],
|
||||
): CommandGroupEntry[] {
|
||||
mapRegister: (register: TRegister) => CommandGroupEntryLike["register"],
|
||||
): CommandGroupEntryLike[] {
|
||||
return resolveCommandGroupEntries(descriptors, specs).map((entry) => ({
|
||||
placeholders: entry.placeholders,
|
||||
register: mapRegister(entry.register),
|
||||
|
||||
@@ -12,6 +12,13 @@ const getPluginCliCommandDescriptorsMock = vi.fn(
|
||||
);
|
||||
|
||||
vi.mock("./core-command-descriptors.js", () => ({
|
||||
CORE_CLI_COMMAND_DESCRIPTORS: [
|
||||
{
|
||||
name: "status",
|
||||
description: "Show status",
|
||||
hasSubcommands: false,
|
||||
},
|
||||
],
|
||||
getCoreCliCommandDescriptors: () => [
|
||||
{
|
||||
name: "status",
|
||||
@@ -23,6 +30,13 @@ vi.mock("./core-command-descriptors.js", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("./subcli-descriptors.js", () => ({
|
||||
SUB_CLI_DESCRIPTORS: [
|
||||
{
|
||||
name: "config",
|
||||
description: "Manage config",
|
||||
hasSubcommands: true,
|
||||
},
|
||||
],
|
||||
getSubCliEntries: () => [
|
||||
{
|
||||
name: "config",
|
||||
|
||||
Reference in New Issue
Block a user