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