This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
forked from jbcarpanelli/spinnies
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
219 lines (184 loc) · 6.82 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// Attribution note:
// These type declarations are modified from type declarations in
// jcarpanelli/spinnies#25 by Adam Jarret <https://github.com/adamjarret>.
export as namespace Spinnies;
export = Spinnies;
import { Color as ChalkColor } from "chalk";
declare namespace Spinnies {
const dots: Spinner;
const dashes: Spinner;
type Color = typeof ChalkColor | "none";
type StopAllStatus = "succeed" | "fail" | "warn" | "stopped";
type SpinnerStatus = StopAllStatus | "spinning" | "non-spinnable";
interface Spinner {
interval: number;
frames: string[];
}
/**
* The configuration for a given spinner
*/
interface SpinnerOptions {
/**
* Text to show in the spinner. If none is provided, the name field will be shown.
*/
text: string;
/**
* Indent the spinner with the given number of spaces.
*/
indent: number;
/**
* Initial status of the spinner.
*/
status: SpinnerStatus;
/**
* The color of the text that accompanies the spinner. Default value is
* `"none"`.
*/
textColor?: Color;
/**
* The color of the spinner or prefix. Default value is `"none"`.
*/
prefixColor?: Color;
/**
* The symbol to be used in place of the spinner on success. The default value is ✓.
*/
succeedPrefix: string;
/**
* The symbol to be used in place of the spinner on failure. The default value is ✖.
*/
failPrefix: string;
/**
* The symbol to be used in place of the spinner on warn. The default value is ⚠.
*/
warnPrefix: string;
/**
* The symbol to be used in place of the spinner on stop. Default value is `""`.
*/
stoppedPrefix?: string;
}
/**
* Contains top-level configuration for the Spinnies class. Also allows the
* caller to override default values used in `SpinnerOptions`.
*/
interface Options {
/**
* The color of the text that accompanies the spinner. Default value is
* `"none"`.
*/
textColor?: Color;
/**
* The color of the spinner. Default value is `"none"`.
*/
prefixColor?: Color;
/**
* The symbol to be used in place of the spinner on success. The default value is ✓.
*/
succeedPrefix: string;
/**
* The symbol to be used in place of the spinner on failure. The default value is ✖.
*/
failPrefix: string;
/**
* The symbol to be used in place of the spinner on stop. Default value is `undefined`.
*/
stoppedPrefix?: string;
/**
* Disable spinner animations (will still print raw messages if `true`). The default value is `false`.
*/
disableSpins: boolean;
/**
* Defines the animated spinner to be used while each spinner is active/spinning.
*/
spinner: Spinner;
}
}
/**
* A class that manages multiple CLI spinners.
*/
declare class Spinnies {
/**
* The current configuration of this Spinnies object.
*/
options: Spinnies.Options;
constructor(options?: Partial<Spinnies.Options>);
/**
* Add a new spinner with the given name.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
add(name: string, text?: string): Spinnies.SpinnerOptions;
add(name: string, options?: Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
add(name: string, textOrOptions?: string | Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
/**
* Get spinner by name.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
pick(name: string): Spinnies.SpinnerOptions;
/**
* Remove spinner with name.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
remove(name: string): Spinnies.SpinnerOptions;
/**
* Updates the spinner with name name with the provided options. Retains
* the value of options that aren't specified.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
update(name: string, text?: string): Spinnies.SpinnerOptions;
update(name: string, options?: Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
update(name: string, textOrOptions?: string | Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
/**
* Sets the specified spinner status as succeed.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
succeed(name: string, text?: string): Spinnies.SpinnerOptions;
succeed(name: string, options?: Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
succeed(name: string, textOrOptions?: string | Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
/**
* Sets the specified spinner status as fail.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
fail(name: string, text?: string): Spinnies.SpinnerOptions;
fail(name: string, options?: Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
fail(name: string, textOrOptions?: string | Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
/**
* Sets the specified spinner status as warn.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
warn(name: string, text?: string): Spinnies.SpinnerOptions;
warn(name: string, options?: Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
warn(name: string, textOrOptions?: string | Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
/**
* Sets the specified spinner status as stopped.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
stop(name: string, text?: string): Spinnies.SpinnerOptions;
stop(name: string, options?: Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
stop(name: string, textOrOptions?: string | Partial<Spinnies.SpinnerOptions>): Spinnies.SpinnerOptions;
/**
* Stops the spinners and sets the non-succeeded and non-failed ones to the provided status.
*
* @returns an object that maps spinner names to final `SpinnerOptions` objects for each spinner, with
* defaults applied
*/
stopAll(status?: Spinnies.StopAllStatus): { [name: string]: Spinnies.SpinnerOptions };
/**
* @returns false if all spinners have succeeded, failed or have been stopped
*/
hasActiveSpinners(): boolean;
}