Added a Spinner class to PrintUtils

This commit is contained in:
Kallum Jones 2022-08-02 15:42:14 +01:00
parent b8435a0a5c
commit 7774386385
No known key found for this signature in database
GPG Key ID: D7F4589C4D7F81A9

View File

@ -1,6 +1,8 @@
import chalk from "chalk";
import ora, { Ora } from "ora";
export default class PrintUtils {
static info(print: string) {
console.log(chalk.white(print));
}
@ -16,4 +18,40 @@ export default class PrintUtils {
static error(print: string) {
console.log(chalk.redBright(print));
}
static Spinner = class {
private spinner: Ora;
constructor(text: string | null | undefined) {
if (text == null || undefined) {
text = "";
}
this.spinner = ora(text);
}
public start() {
this.spinner.start();
}
public stop() {
this.spinner.stop();
}
public error() {
this.spinner.fail();
}
public succeed() {
this.spinner.succeed();
}
public updateText(text: string) {
this.spinner.info(text);
}
public clear() {
this.spinner.clear();
}
}
}