2.0.2 • Published 4 years ago
@open-tech-world/cli-progress-bar v2.0.2
@open-tech-world/cli-progress-bar

Node.js CLI progress bar.
Internally it uses @open-tech-world/es-cli-styles for terminal colors. Refer it for supported colors.
Installation
Using npm
$ npm install @open-tech-world/cli-progress-barUsing Yarn
$ yarn add @open-tech-world/cli-progress-barUsage
import { ProgressBar } from '@open-tech-world/cli-progress-bar';
const pBar = new ProgressBar({ prefix: 'Downloading' });
pBar.run({ value: 0, total: 100 });
pBar.run({ value: 50, total: 100 });
pBar.run({ value: 100, total: 100, prefix: 'Download Completed!' });API
new ProgressBar(options?: Partial\<IOptions>)
It creates a new instance of the ProgressBar.
options:
| Name | Type | Default | Description |
|---|---|---|---|
| stream | NodeJS.WriteStream | process.stderr | The stream to use. |
| width | number | 30 | The size of the progress bar. |
| prefix | string | '' | The string to be prefixed progress bar. |
| suffix | string | '' | The string to be suffixed progress bar. |
| color | string | 'green' | The color to render the progress bar. Refer the supported color names here. |
| autoClear | boolean | false | If true, then it auto clears the progress bar when it reaches 100%. |
Instance methods:
run(options: IRunOptions): void
Runs the current progress bar instance with the given values & options.
options:
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| value | number | NaN | Yes | The current value of the progress bar. |
| total | number | NaN | Yes | The total value for the progress bar. |
| prefix | string | '' | No | The string to be prefixed progress bar. |
| suffix | string | '' | No | The string to be suffixed progress bar. |
| color | string | 'green' | No | The color to render the progress bar. Refer the supported color names here. |
stop(clear = false): void
Stops the current progress bar instance with the current state and optionally clears the progress bar.
pBar.stop(); // It just stops the progress bar.
pBar.stop(true); // It stops & removes the progress bar.License
Copyright (c) 2021, Thanga Ganapathy (MIT License).