UNPKG

@geeth.io/command-engine

Version:

A minimal, class-based CLI command engine with support for nested commands, options, and attributes.

44 lines (43 loc) 1.21 kB
import { CommandEngine } from "./command-engine"; export type ActionHandler = (args: { attributes: Record<string, string>; options: Record<string, string | boolean>; }) => void; type DefaultValue = string | number | boolean | any[] | Record<string, any>; export interface OptionDef { flag: string; description: string; required?: boolean; alias?: string; default?: DefaultValue; } export interface AttributeDef { name: string; description: string; required?: boolean; default?: DefaultValue; } export interface CommandDef { name: string; description: string; attributes: AttributeDef[]; options: OptionDef[]; action: ActionHandler; help?: () => void; } export interface CommandBuilder { addAttribute(attrName: string, description: string, config?: { required?: boolean; default?: DefaultValue; }): CommandBuilder; addOption(flag: string, description: string, config?: { required?: boolean; alias?: string; default?: DefaultValue; }): CommandBuilder; action(fn: ActionHandler): CommandBuilder; } export interface GeethCliPlugin { register(cli: CommandEngine): void; } export {};