1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import * as clc from 'cli-color';
|
7 |
|
8 | export interface LineBufferOptions {
|
9 | x?: number | undefined;
|
10 | y?: number | undefined;
|
11 | width?: number | 'console' | undefined;
|
12 | height?: number | 'console' | undefined;
|
13 | scroll?: number | undefined;
|
14 | }
|
15 |
|
16 | export class LineBuffer {
|
17 | |
18 |
|
19 |
|
20 |
|
21 | constructor(options: LineBufferOptions);
|
22 |
|
23 | /**
|
24 | * Return the height of the `LineBuffer`, when specified as `console`
|
25 | */
|
26 | height(): number;
|
27 |
|
28 | /**
|
29 | * Return the width of the `LineBuffer`, when specified as `console`
|
30 | */
|
31 | width(): number;
|
32 |
|
33 | /**
|
34 | * Put a `Line` object into the `LineBuffer`
|
35 | * @param line The line object to put into the buffer
|
36 | */
|
37 | addLine(line: Line): void;
|
38 |
|
39 | /**
|
40 | * If you don't have enough lines in the buffer, this will fill the reset of
|
41 | * the lines with empty spaces
|
42 | */
|
43 | fill(): void;
|
44 |
|
45 | /**
|
46 | * Draw the `LineBuffer` to screen
|
47 | */
|
48 | output(): void;
|
49 | }
|
50 |
|
51 | /**
|
52 | * This chainable object can be used to generate a line of text with columns, padding, and fill
|
53 | */
|
54 | export class Line {
|
55 | |
56 |
|
57 |
|
58 |
|
59 | constructor(buffer?: LineBuffer);
|
60 |
|
61 | /**
|
62 | * Output `width` characters of blank space
|
63 | * @param width Number of characters to print
|
64 | */
|
65 | padding(width: number): Line;
|
66 |
|
67 | /**
|
68 | * Output text within a column of the specified width
|
69 | * @param text Text to print
|
70 | * @param width Width of the column
|
71 | * @param styles List of `cli-color` styles to apply
|
72 | */
|
73 | column(text: string, width: number, styles?: clc.Format[]): Line;
|
74 |
|
75 | /**
|
76 | * At the end of a line, fill the rest of the columns to the right edge
|
77 | */
|
78 | fill(): Line;
|
79 |
|
80 | /**
|
81 | * Print the generated line of text to the console
|
82 | */
|
83 | output(): Line;
|
84 |
|
85 | /**
|
86 | * Return the contents of this line as a string
|
87 | */
|
88 | contents(): string;
|
89 |
|
90 | /**
|
91 | * Store this line into the buffer
|
92 | */
|
93 | store(): void;
|
94 | }
|
95 |
|
96 | /**
|
97 | * Creates a basic horizontal gauge to the screen
|
98 | * @param value The current value of the metric being displayed by this gauge
|
99 | * @param maxValue The highest possible value of the metric being displayed
|
100 | * @param guageWidth How many columns widt to draw the gauge
|
101 | * @param dangerZone The point after which the value will be drawn in red because it's too high
|
102 | * @param suffix A value to output after the gauge itself
|
103 | */
|
104 | export function Gauge(
|
105 | value: number,
|
106 | maxValue: number,
|
107 | guageWidth: number,
|
108 | dangerZone: number,
|
109 | suffix: string,
|
110 | ): string;
|
111 |
|
112 | /**
|
113 | * A simple command line sparkline that draws a series of values, and highlights the peak for the period
|
114 | * @param values An array of values to go into the sparkline
|
115 | * @param suffix A suffix to use when drawing the current and max values at the end of the sparkline
|
116 | */
|
117 | export function Sparkline(values: number[], suffix: string): string;
|
118 |
|
119 | export class Progress {
|
120 | |
121 |
|
122 |
|
123 |
|
124 | constructor(length: number);
|
125 |
|
126 | /**
|
127 | * Returns the progress bar min/max context to write to stdout
|
128 | * @param currentValueOrPercent Current value (or percent) of the progress bar
|
129 | * @param maxValue Maximum value of the progress bar
|
130 | */
|
131 | update(currentValueOrPercent: number, maxValue?: number): string;
|
132 | }
|
133 |
|
134 | export class Spinner {
|
135 | |
136 |
|
137 |
|
138 |
|
139 |
|
140 | constructor(statusText: string, style?: string[]);
|
141 |
|
142 | /**
|
143 | * Show the spinner on the screen
|
144 | */
|
145 | start(): void;
|
146 |
|
147 | /**
|
148 | * Update the status message that follows the spinner
|
149 | * @param statusMessage Message to be displayed
|
150 | */
|
151 | message(statusMessage: string): void;
|
152 |
|
153 | /**
|
154 | * Erase the spinner from the screen
|
155 | */
|
156 | stop(): void;
|
157 | }
|