ora-progress-bar

A progress bar based on ora library

Usage no npm install needed!

<script type="module">
  import oraProgressBar from 'https://cdn.skypack.dev/ora-progress-bar';
</script>

README

Ora Progress Bar

A cli progress bar based on ora library.

NPM link

Usage

Create a ProgressBar(title,numberOfSteps,options?)

const ProgressBar = require("ora-progress-bar");

const progressBar = new ProgressBar("Current Progress", 100);

The options parameter is optional if you want to customize the ora spinner you can pass them see.

Increase the progress using progressBar.progress(progress=1)

progressBar.progress();

progressBar.progress(5);

Fail or Succeed

By default when the progressBar reaches its goal, it stops and succeeds. But you can force them to fail or succeed manually.

try {
  // do stuff
  progressBar.progress();
} catch (e) {
  progressBar.fail();
}
if (flag) {
  progressBar.succeed();
} else {
  progressBar.progress();
}

Update goal and current progress on the run

if (newWorkReceived) progressBar.updateGoal(progressBar.goal + newWork.length);
if (batchFailed) progressBar.updateProgress(0);

Note

Only one progress bar can be active at a time.