import Option from './Option'; import type { OptionConfig } from './Option'; import type CAC from './CLI'; export type { CommandConfig, CommandExample, HelpCallback }; declare interface CommandArg { required: boolean value: string variadic: boolean } declare interface HelpSection { title?: string body: string } declare interface CommandConfig { allowUnknownOptions?: boolean ignoreOptionDefaultValue?: boolean } export declare interface HookContext { command: Command args: unknown[] options: ParsedOptions next?: () => void | Promise } declare type HelpCallback = (_sections: HelpSection[]) => void | HelpSection[]; declare type CommandExample = ((_bin: string) => string) | string; /** Parsed command-line options */ declare type ParsedOptions = Record; export type HookHandler = (_context: HookContext) => void | Promise; export declare class Command { options: Option[]; aliasNames: string[]; name: string; namespace?: string; args: CommandArg[]; commandAction?: (...args: unknown[]) => unknown; usageText?: string; versionNumber?: string; examples: CommandExample[]; helpCallback?: HelpCallback; globalCommand?: GlobalCommand; beforeHooks: HookHandler[]; afterHooks: HookHandler[]; middleware: HookHandler[]; public rawName: string; public description: string; public config: CommandConfig; public cli: CAC; constructor(rawName: string, description: string, config: CommandConfig, cli: CAC); usage(text: string): this; allowUnknownOptions(): this; ignoreOptionDefaultValue(): this; version(version: string, customFlags?: string): this; example(example: CommandExample): this; option(rawName: string, description: string, config?: OptionConfig): this; alias(name: string): this; action(callback: (...args: any[]) => unknown): this; before(handler: HookHandler): this; after(handler: HookHandler): this; use(handler: HookHandler): this; isMatched(name: string): boolean; get isDefaultCommand(): boolean; get isGlobalCommand(): boolean; get displayName(): string; hasOption(name: string): boolean; outputHelp(): void; outputVersion(): void; get usageLine(): string; checkRequiredArgs(): void; checkUnknownOptions(): void; checkOptionValue(): void; } declare class GlobalCommand extends Command { constructor(cli: CAC); } export { GlobalCommand }; export default Command;