/** * Parse a line into arguments. * Supports single and double quoted strings as well as backslash escaping. */ export declare function splitIntoArgs(input: string): string[]; /** Where a shell reads keystrokes from, i.e. the parts of `NodeJS.ReadStream` it uses. */ export interface ShellInput { on(event: 'data', listener: (chunk: string | Uint8Array) => void): unknown; off?(event: 'data', listener: (chunk: string | Uint8Array) => void): unknown; /** Hand over keystrokes as they are typed, instead of a line at a time with editing and echo */ setRawMode?(raw: boolean): unknown; resume?(): unknown; pause?(): unknown; readonly isTTY?: boolean; } /** * Where a shell draws, i.e. the parts of `NodeJS.WriteStream` it uses. */ export interface ShellOutput { write(data: string): unknown; readonly columns?: number; readonly rows?: number; } export interface ShellOptions { /** * The stream keystrokes are read from, e.g. `process.stdin`. * The shell does its own line editing, so it is put into raw mode. */ stdin: ShellInput; /** The stream the prompt and the line being edited are written to, e.g. `process.stdout`. */ stdout: ShellOutput; /** The prompt to use, can be a getter. */ readonly prompt?: string; /** The length to use for the prompt. Useful if escape sequences are used in the prompt. */ readonly promptLength?: number; /** The handler for when a line is parsed */ onLine?(this: void, line: string): unknown; } export interface ShellContext extends Required { /** The input currently being shown */ input: string; /** Where the cursor is in `input`. */ cursor: number; /** The index for which input is being shown */ index: number; /** The current, uncached input */ currentInput: string; /** array of previous inputs */ inputs: string[]; /** Stop reading from `stdin` and put it back the way it was found */ close(): void; } /** * A simple wrapper for a pair of streams that makes implementing shells easier. */ export declare function createShell(options: ShellOptions): ShellContext;