UNPKG

@stacksjs/clapp

Version:

A toolkit for building CLI prompts in TypeScript.

42 lines 1.51 kB
import { EventEmitter } from 'node:events'; import Command, { GlobalCommand } from './Command'; import mri from 'mri'; import type { CommandConfig, CommandExample, HelpCallback } from './Command'; import type { OptionConfig } from './Option'; /** * @param name The program name to display in help and version message */ export declare const cli: (name?) => CLI; declare interface ParsedArgv { args: ReadonlyArray<string> options: { [k: string]: any } } export declare class CLI 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?: any); 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?: any): this; example(example: CommandExample): this; outputHelp(): void; outputVersion(): void; private setParsedInfo({ args, options }: ParsedArgv, matchedCommand?: Command, matchedCommandName?: string): void; unsetMatchedCommand(): void; parse(argv?: string[], { run }?: { run?: boolean }): ParsedArgv; private mri(argv: string[], command?: Command): ParsedArgv; runMatchedCommand(): void; } export default CLI;