| | import { EventEmitter } from 'events'; |
| |
|
| | interface OptionConfig { |
| | default?: any; |
| | type?: any[]; |
| | } |
| | declare class Option { |
| | rawName: string; |
| | description: string; |
| | |
| | name: string; |
| | |
| | names: string[]; |
| | isBoolean?: boolean; |
| | required?: boolean; |
| | config: OptionConfig; |
| | negated: boolean; |
| | constructor(rawName: string, description: string, config?: OptionConfig); |
| | } |
| |
|
| | interface CommandArg { |
| | required: boolean; |
| | value: string; |
| | variadic: boolean; |
| | } |
| | interface HelpSection { |
| | title?: string; |
| | body: string; |
| | } |
| | interface CommandConfig { |
| | allowUnknownOptions?: boolean; |
| | ignoreOptionDefaultValue?: boolean; |
| | } |
| | declare type HelpCallback = (sections: HelpSection[]) => void | HelpSection[]; |
| | declare type CommandExample = ((bin: string) => string) | string; |
| | declare class Command { |
| | rawName: string; |
| | description: string; |
| | config: CommandConfig; |
| | cli: CAC; |
| | options: Option[]; |
| | aliasNames: string[]; |
| | name: string; |
| | args: CommandArg[]; |
| | commandAction?: (...args: any[]) => any; |
| | usageText?: string; |
| | versionNumber?: string; |
| | examples: CommandExample[]; |
| | helpCallback?: HelpCallback; |
| | globalCommand?: GlobalCommand; |
| | 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[]) => any): this; |
| | |
| | |
| | |
| | |
| | isMatched(name: string): boolean; |
| | get isDefaultCommand(): boolean; |
| | get isGlobalCommand(): boolean; |
| | |
| | |
| | |
| | |
| | hasOption(name: string): Option | undefined; |
| | outputHelp(): void; |
| | outputVersion(): void; |
| | checkRequiredArgs(): void; |
| | |
| | |
| | |
| | |
| | |
| | checkUnknownOptions(): void; |
| | |
| | |
| | |
| | checkOptionValue(): void; |
| | } |
| | declare class GlobalCommand extends Command { |
| | constructor(cli: CAC); |
| | } |
| |
|
| | interface ParsedArgv { |
| | args: ReadonlyArray<string>; |
| | options: { |
| | [k: string]: any; |
| | }; |
| | } |
| | declare class CAC extends EventEmitter { |
| | |
| | name: string; |
| | commands: Command[]; |
| | globalCommand: GlobalCommand; |
| | matchedCommand?: Command; |
| | matchedCommandName?: string; |
| | |
| | |
| | |
| | rawArgs: string[]; |
| | |
| | |
| | |
| | args: ParsedArgv['args']; |
| | |
| | |
| | |
| | options: ParsedArgv['options']; |
| | showHelpOnExit?: boolean; |
| | showVersionOnExit?: boolean; |
| | |
| | |
| | |
| | constructor(name?: string); |
| | |
| | |
| | |
| | |
| | |
| | usage(text: string): this; |
| | |
| | |
| | |
| | command(rawName: string, description?: string, config?: CommandConfig): Command; |
| | |
| | |
| | |
| | |
| | |
| | option(rawName: string, description: string, config?: OptionConfig): this; |
| | |
| | |
| | |
| | |
| | help(callback?: HelpCallback): this; |
| | |
| | |
| | |
| | |
| | version(version: string, customFlags?: string): this; |
| | |
| | |
| | |
| | |
| | |
| | example(example: CommandExample): this; |
| | |
| | |
| | |
| | |
| | |
| | |
| | outputHelp(): void; |
| | |
| | |
| | |
| | |
| | outputVersion(): void; |
| | private setParsedInfo; |
| | unsetMatchedCommand(): void; |
| | |
| | |
| | |
| | parse(argv?: string[], { |
| | |
| | run, }?: { |
| | run?: boolean | undefined; |
| | }): ParsedArgv; |
| | private mri; |
| | runMatchedCommand(): any; |
| | } |
| |
|
| | |
| | |
| | |
| | declare const cac: (name?: string) => CAC; |
| |
|
| | export default cac; |
| | export { CAC, Command, cac }; |
| |
|