commandzen
Version:
A command-line argument parsing library that allows for quick and easy parsing of command-line arguments.
27 lines (26 loc) • 981 B
TypeScript
/// <reference types="node" />
import { EventEmitter } from "events";
import { Option, OptionProps } from "../option";
export type CommandProps = {
name: string;
description: string;
aliases?: string[];
options?: Option[];
subcommands?: Map<string, Command>;
};
export declare class Command extends EventEmitter {
readonly name: string;
readonly description: string;
readonly aliases: string[];
readonly options: Option[];
readonly subcommands: Map<string, Command>;
private constructor();
static create(props: CommandProps): Command;
addSubcommand(command: Command): Command;
addOption(...option: OptionProps[]): Command;
addAlias(...aliases: string[]): Command;
findOption(flag: string): Option | undefined;
findSubcommand(name: string): Command | undefined;
help(indentationLevel?: number, fullName?: string, subcommandIndex?: string): void;
registerAction<T>(callback: (props: T) => void): Command;
}