@ideascol/cli-maker
Version:
A simple library to help create CLIs
91 lines (90 loc) • 3.42 kB
TypeScript
import { Command, CLIOptions, SetupCommandOptions, SessionOptions } from '../interfaces';
export declare class CLI {
private name;
private description;
private options?;
private commands;
private validator;
executableName: string;
private resolvedIntro?;
private setupSteps?;
private setupConfigFileName?;
constructor(name: string, description: string, options?: CLIOptions | undefined);
private getBinName;
getCommands(): Command[];
getName(): string;
getDescription(): string;
getOptions(): CLIOptions | undefined;
command(command: Command): void;
setupCommand(options: SetupCommandOptions): this;
/**
* Get a specific config value from the setup config.
* For non-Password fields, returns the raw value.
* For Password fields, prompts for passphrase if not provided.
* Passphrase can be provided via CLI_PASSPHRASE environment variable to skip prompting.
*/
getConfigValue(key: string, passphrase?: string): Promise<any>;
/**
* Load all config values from the setup config.
* For Password fields, prompts for passphrase if not provided.
* Passphrase can be provided via CLI_PASSPHRASE environment variable to skip prompting.
*/
loadConfig(passphrase?: string): Promise<Record<string, any>>;
/**
* Start an interactive REPL session with slash commands, tool calls,
* streaming output, and conversation history.
* The returned promise resolves when the user exits the session.
*/
startSession(options: SessionOptions): Promise<void>;
setOptions(options: CLIOptions): void;
parse(argv: string[]): void;
help(): void;
private showBranding;
private commandHelp;
private findCommand;
private findSubcommand;
private showUnknownCommandError;
private getMissingParams;
private getOptionalParams;
private handleMissingParams;
private parseArgs;
private validateParam;
private findParamType;
private showIntroIfNeeded;
private resolveIntroOptions;
private renderIntroAnimation;
private buildIntroLines;
private getIntroMarkerPath;
private hasSeenIntro;
private markIntroSeen;
private blockingSleep;
private revealText;
private colorizeRainbow;
private extractIntroFlags;
private promptForMissingParams;
private promptWithArrows;
/**
* Interactive array builder. Loops over itemParams, asking "add another?" between iterations.
* Each item is a sub-prompt context (its own answers scope).
*/
private promptArray;
/**
* Searchable + paginated list picker. Type to filter, ↑/↓ to move,
* PageUp/PageDown jump a page, Home/End jump to ends, Esc clears filter,
* Enter selects, Ctrl+C cancels.
*/
private promptSearchableList;
/**
* Static method to prompt for visible input.
* @param question The question to ask the user
* @returns Promise that resolves with the user's answer
*/
static askQuestion(question: string): Promise<string>;
/**
* Static method to prompt for hidden input (password-like).
* The input is not displayed on the screen, asterisks are shown instead.
* @param question The question to ask the user
* @returns Promise that resolves with the user's hidden input
*/
static askHiddenQuestion(question: string): Promise<string>;
}