UNPKG

2.01 kBTypeScriptView Raw
1export declare class Output {
2 private exitCode;
3 private data;
4 private prettyError;
5 static create(): Output;
6 static errorOutput(error?: string | Error, exitCode?: number): Output;
7 /**
8 * Exit code to use upon send.
9 *
10 * NOTE: Exit codes 1 - 2, 126 - 165, and 255 have special meanings
11 * and should therefore be avoided for user-specified exit parameters.
12 * Try restricting user-defined exit codes to the range 64 - 113 (in addition to 0, for success).
13 *
14 * 1 - Catchall for general errors
15 * 2 - Misuse of shell builtins (according to Bash documentation)
16 * 126 - Command invoked cannot execute
17 * 127 - “command not found”
18 * 128 - Invalid argument to exit
19 * 128+n - Fatal error signal “n”
20 * 130 - Script terminated by Control-C
21 * 255\* - Exit status out of range
22 *
23 * @see http://tldp.org/LDP/abs/html/exitcodes.html
24 *
25 * @param {Number} exitCode
26 *
27 * @return {this}
28 */
29 setExitCode(exitCode: number): this;
30 addData(...data: any[]): this;
31 success(message: string, data?: any): void;
32 resetData(): this;
33 addHorizontalTable(head: string[], data: Array<string>[], options?: any): this;
34 addVerticalTable(data: {
35 [key: string]: string;
36 }[], options?: any): this;
37 addCrossTable(head: string[], data: {
38 [key: string]: string[];
39 }[], options?: any): this;
40 /**
41 * Add/set an error to output.
42 *
43 * @param {Error|string} [error] The error to write. Default to "Unknown error".
44 * @param {Number|null} [exitCode] The code to exit with. Default to 1. Use null to not change the exitCode.
45 * @param {boolean} [clear] Clear previously set data. Default to false.
46 *
47 * @return {this}
48 */
49 error(error?: Error | string, exitCode?: number, clear?: boolean): this;
50 /**
51 * Write the output to the console.
52 */
53 flush(): void;
54 send(): void;
55}