UNPKG

@rawcmd/core

Version:
44 lines (43 loc) 1.6 kB
import { CommandOption, CommandOptionData } from './command-option'; import { Typewriter } from '../writers/typewriter'; import { CommandResolver } from '../types'; import { CommandLink, CommandLinkData } from './command-link'; import { Spinwriter } from '../writers/spinwriter'; export declare type CommandData<Context> = (Command<Context> | CommandRecipe<Context> | ((config: CommandConfig<Context>) => (Command<Context> | CommandRecipe<Context>))); export interface CommandRecipe<Context> { name?: string; description?: string; summary?: string; options?: CommandOptionData[]; commands?: CommandData<Context>[]; links?: CommandLinkData[]; resolver?: CommandResolver; } export interface CommandConfig<Context> { parent?: Command<Context>; context?: Context; typewriter?: Typewriter; spinwriter?: Spinwriter; } export declare class Command<Context = any> { __config: CommandConfig<Context>; name: string; description: string; summary: string; options: CommandOption[]; commands: Command<Context>[]; links: CommandLink[]; resolver: CommandResolver; constructor(recipe?: CommandData<Context>, config?: CommandConfig<Context>); getParent(): Command<Context>; getAncestors(): Command<Context>[]; getContext(): Context; getTypewriter(): Typewriter; getSpinwriter(): Spinwriter; perform(...args: string[]): Promise<this>; write(...messages: string[]): this; print(...messages: string[]): this; break(): this; spin(message: string): this; clone(recipe?: CommandRecipe<Context>): this; }