fix: commander issues
This commit is contained in:
parent
28066c7fff
commit
38c9a8ce9e
|
|
@ -12,18 +12,20 @@ export const defaultCommands: Record<string, MdCommanderCommand> = {
|
||||||
help: {
|
help: {
|
||||||
command: "help",
|
command: "help",
|
||||||
description: "显示帮助信息或特定命令的帮助",
|
description: "显示帮助信息或特定命令的帮助",
|
||||||
options: {
|
parameters: [
|
||||||
cmd: {
|
{
|
||||||
option: "cmd",
|
name: "cmd",
|
||||||
description: "要查询的命令名",
|
description: "要查询的命令名",
|
||||||
type: "enum",
|
type: "enum",
|
||||||
values: [], // 运行时填充
|
values: [], // 运行时填充
|
||||||
|
required: false,
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
handler: (args) => {
|
handler: (args) => {
|
||||||
if (args.cmd) {
|
const cmdName = args.params.cmd;
|
||||||
|
if (cmdName) {
|
||||||
return {
|
return {
|
||||||
message: `命令:${args.cmd}\n描述:${defaultCommands[args.cmd]?.description || "无描述"}`,
|
message: `命令:${cmdName}\n描述:${defaultCommands[cmdName]?.description || "无描述"}`,
|
||||||
type: "info",
|
type: "info",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -286,9 +288,9 @@ export function useCommander(
|
||||||
|
|
||||||
const commands = { ...defaultCommands, ...customCommands };
|
const commands = { ...defaultCommands, ...customCommands };
|
||||||
|
|
||||||
// 更新 help 命令的选项值
|
// 更新 help 命令的参数值
|
||||||
if (commands.help?.options?.cmd) {
|
if (commands.help?.parameters?.[0]) {
|
||||||
commands.help.options.cmd.values = Object.keys(commands).filter(
|
commands.help.parameters[0].values = Object.keys(commands).filter(
|
||||||
(k) => k !== "help",
|
(k) => k !== "help",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
export { CommanderInput } from './CommanderInput';
|
||||||
|
export type { CommanderInputProps } from './CommanderInput';
|
||||||
|
export { CommanderEntries } from './CommanderEntries';
|
||||||
|
export type { CommanderEntriesProps } from './CommanderEntries';
|
||||||
|
export type {
|
||||||
|
MdCommanderProps,
|
||||||
|
MdCommanderCommand,
|
||||||
|
MdCommanderOption,
|
||||||
|
MdCommanderParameter,
|
||||||
|
MdCommanderOptionType,
|
||||||
|
CommanderEntry,
|
||||||
|
CompletionItem,
|
||||||
|
} from './types';
|
||||||
Loading…
Reference in New Issue