import TypedEventEmitter from "typed-emitter"; import { Argv, ParserConfigurationOptions } from "yargs"; import { Command } from "./command.js"; import { Repl } from "./repl.js"; type Events = { run: (command: string | readonly string[]) => void; }; type ProgramOptions = { /** * Program description. Can also be set by calling * `program().description(...)`. * * Defaults to `undefined`. */ description?: string; /** * Sets a custom REPL prompt. Can also be set by calling * `program().prompt(...)`. * * Defaults to `> `. */ prompt?: string; /** * Whether or not to add a global help command that displays an overview of * commands. * * Defaults to `true`. */ help?: boolean; /** * Whether or not to add a global version command that displays the version as * specified in the package.json file. * * Defaults to `true`. */ version?: boolean; /** * Use this history file. Set to NULL to disable history file. * * Defaults to `{homedir}/.bandersnatch_history`. */ historyFile?: string | null; /** * Specifies whether to add a default behaviour for an `exit` command. * * Takes a boolean or a function argument: * - `false` installs no handler * - `true` will install the default handler * - a given function will be installed as the handler * * Defaults to `() => process.exit()`. */ exit?: boolean | (() => void); /** * Pass Yargs parser configuration, for available options, see * https://github.com/yargs/yargs/blob/main/docs/advanced.md#customizing-yargs-parser. * * Defaults to `undefined`. */ parserConfiguration?: Partial; }; /** * Creates a new bandersnatch program. */ export declare function program(options?: ProgramOptions): Program; declare const Program_base: new () => TypedEventEmitter; export declare class Program extends Program_base { options: ProgramOptions; private commands; private history?; private replInstance?; constructor(options?: ProgramOptions); /** * Set the program description. */ description(description: string): this; /** * Sets a custom REPL prompt. */ prompt(prompt: string): this; /** * Create a new yargs instance. This method may change at any time, not * intended for public use. * * @private */ createYargsInstance(overrideParserConfiguration?: Partial): Argv<{}>; /** * Adds a new command to the program. */ add(command: Command): this; /** * Adds a new command to the program and marks it as the default command. */ default(command: Command): this; /** * Evaluate command (or process.argv) and return promise. */ run(command?: string | readonly string[]): Promise; /** * Run event loop which reads command from stdin. */ repl(): Repl; /** * When argv is set, run the program, otherwise start repl loop. */ runOrRepl(): Promise | Repl; /** * Returns `true` if program is running a repl loop, `false` otherwise. */ isRepl(): boolean; /** * Method to execute when a failure occurs, rather than printing the failure * message. * * Called with the failure message that would have been printed, the Error * instance originally thrown and yargs state when the failure occured. */ private failHandler; } export {};