import { Graph, IPoint } from "../core"; export interface CommandOption { name: string; args: string[]; } /** * 命令构成 * 命令本身 命令参数 选项 选项参数 选项 选项参数... */ export interface Commander { /** * 命令 */ command: Command; /** * 命令的参数 */ args: string[]; /** * 命令的选项 数组 以及选项参数 */ options?: CommandOption[]; } export interface Consumer { (option: CommandOption): void; } export declare class Helper { private readonly command; private explain?; private readonly args; private options; private examples; constructor(command: string); remark(explain: string): this; arg(name: string, describe: string): this; option(name: string, describe: string): this; example(example: string): this; toString(): string; } export declare abstract class CommandExecutor { protected command: Command; protected helper: Helper; protected constructor(command: Command); /** * 获取坐标点 x,y * @protected * @param arg */ protected getPoint(arg: string): IPoint; protected getNumber(arg: string): number; protected fill(graph: Graph, args: string[]): void; protected border(graph: Graph, args?: string[]): void; protected attr(graph: Graph, args: string[]): void; protected setOptions(graph: Graph, options?: CommandOption[], consumer?: Consumer): void; abstract exec(commander: Commander): Graph; help(): string; } export interface ICommandProxy { sector(command: Command): CommandExecutor; circle(command: Command): CommandExecutor; ellipse(command: Command): CommandExecutor; line(command: Command): CommandExecutor; polyline(command: Command): CommandExecutor; coordinate(command: Command): CommandExecutor; defs(command: Command): CommandExecutor; use(command: Command): CommandExecutor; symbol(command: Command): CommandExecutor; triangle(command: Command): CommandExecutor; polygon(command: Command): CommandExecutor; rectangle(command: Command): CommandExecutor; text(command: Command): CommandExecutor; } export type Command = keyof ICommandProxy; /** * 命令解析器 * 命令格式为 command arg0 arg1 --option optionArg1 optionArg2 */ export declare class CommandAnalyzer { static analyze(string: string): Commander; }