From 7774386385647904eefbec1efa6daf20f546e50a Mon Sep 17 00:00:00 2001 From: Kallum Jones Date: Tue, 2 Aug 2022 15:42:14 +0100 Subject: [PATCH] Added a Spinner class to PrintUtils --- src/util/print_utils.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/util/print_utils.ts b/src/util/print_utils.ts index 43ed73b..b9e393d 100644 --- a/src/util/print_utils.ts +++ b/src/util/print_utils.ts @@ -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(); + } + } } \ No newline at end of file