import { type ArgsOrigin, type CommandAction, type CommandArgType, type CommandArgTypeSign, type CommandConfig, type OptsOrigin, UserAccess } from '../types'; import { CommandError } from '../utils/error'; /** Command argument */ interface CommandArg { /** Argument displayname */ name: string; /** Argument type */ type: CommandArgTypeSign; /** Argument is wether optional */ optional: boolean; /** Argument default value, if exists so `optional` is true */ default?: CommandArgType; /** Argument is wether rest arguments */ rest: boolean; } /** Command option */ interface CommandOption { /** Option short name, composed a uppercase letter */ name: string; /** Option type */ type: CommandArgTypeSign; /** Option full name (real name), composed some lowercase letters and connect by `-` between word and word */ realname: string; /** Option description */ description?: string; } /** * Command meta data. * * @template Args - Command arguments * @template Opts - Command options */ interface CommandData { /** Command root content */ root: string; /** Command alias (need bring command prefix) */ alias: string[]; /** Command shortcut (needn't bring command prefix) */ shortcut: string[]; /** Command is wether hide at the menu */ hide: boolean; /** Command arguments */ args: CommandArg[]; /** Command options */ options: CommandOption[]; /** Command require message scope (session type) */ scope: CommandConfig['scope']; /** Command require user access level */ access: UserAccess; /** Command description */ description?: string; /** Command help message, it has more details than `description` */ help?: string; /** Command action */ action?: CommandAction; } type GetSignType = T extends `${string}number${string}` ? number : T extends `${string}boolean${string}` ? boolean : string; type GetArgCtn