Skip to content

Latest commit

 

History

History
62 lines (42 loc) · 1.26 KB

README.md

File metadata and controls

62 lines (42 loc) · 1.26 KB

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.