export declare type ExitStatus = number | Error; export declare class ShellPromise extends Promise { } export declare class ExitError extends RangeError { cmdline: string; code: number; constructor(cmdline: string, code: number); } export declare class SignalError extends Error { cmdline: string; signal: string; constructor(cmdline: string, signal: string); } export interface CmdFunction { (...args: string[]): ShellPromise; } export declare type ShellFunc = () => Promise; export declare type Program = string | ShellFunc | Cmd; export interface Cmd extends CmdFunction { prog: Program; args?: string[]; } export declare function cmd(prog: Program, ...args: string[]): Cmd; export declare function subshell(body: ShellFunc): Cmd; export interface ShellListener { started?(info: JobInfo): void; finished?(info: JobInfo, status: ExitStatus): void; failed?(info: JobInfo, err: Error): void; } export declare class JobInfo { shell: Shell; ident: number; context: Context; prog: Program; args: string[]; pid: number; readonly cmdline: string; } export declare type Stream = any; export declare class Context { dir?: string; env?: object; throwFlag?: boolean; traceFlag?: boolean; detachedFlag?: boolean; '<'?: string | Stream; '>'?: string | Stream; '>&'?: string | Stream; '>>'?: string | Stream; '>>&'?: string | Stream; listener?: ShellListener; listeners?: ShellListener[]; } export declare type ExecArg = string | Context; export declare function exec(p: Program, ...arglist: ExecArg[]): ShellPromise; export declare function output(p: Program, ...arglist: ExecArg[]): Promise; export declare function cmdline(p: Program, ...arglist: ExecArg[]): string; export interface Shell { context: Context; listenerAdd(listener: ShellListener): void; listenerDel(listener: ShellListener): ShellListener; listenerDelAll(): void; result(value: ExitStatus): ExitStatus; exit(code: number): void; } export declare function shell(): Shell;