@sudoo/coco
Version:
:ocean: A simple command line tool framework
26 lines (25 loc) • 1.19 kB
TypeScript
import { Argument } from "../argument/argument";
import { Option } from "../option/option";
export declare type Executable<T = Record<string, string | undefined>> = (inputs: T) => Promise<void> | void;
export declare class Command {
static create(command: string): Command;
static commands(commands: string[]): Command;
static multiple(...commands: string[]): Command;
static root(): Command;
private readonly _command;
private readonly _arguments;
private readonly _options;
private readonly _listeners;
private constructor();
get commands(): string[];
get simulate(): string;
match(argv: string[]): boolean;
argument(arg: Argument, ...args: Argument[]): this;
arguments(args: Argument[]): this;
option(option: Option, ...options: Option[]): this;
options(options: Option[]): this;
execute(args: string[], globalOptions: Option[]): Promise<void>;
then<T extends Record<string, string | undefined> = Record<string, string | undefined>>(func: Executable<T>): this;
findOption(key: string, globalOptions: Option[]): Option | null;
parseArgs(args: string[], globalOptions: Option[]): Record<string, string>;
}