### Install ansi-colors Source: https://github.com/npkgz/cli-progress/blob/master/examples/README.md Installs the 'ansi-colors' library, which is an optional dependency for styling cli-progress output. ```bash yarn install ansi-colors ``` -------------------------------- ### Single Bar Mode Example Source: https://github.com/npkgz/cli-progress/blob/master/README.md Provides an example of using the SingleBar with custom formatting, including colors and specific bar characters. It shows how to start, update, and stop the bar. ```javascript const cliProgress = require('cli-progress'); // note: you have to install this dependency manually since it's not required by cli-progress const colors = require('ansi-colors'); // create new progress bar const b1 = new cliProgress.SingleBar({ format: 'CLI Progress |' + colors.cyan('{bar}') + '| {percentage}% || {value}/{total} Chunks || Speed: {speed}', barCompleteChar: '\u2588', barIncompleteChar: '\u2591', hideCursor: true }); // initialize the bar - defining payload token "speed" with the default value "N/A" b1.start(200, 0, { speed: "N/A" }); // update values b1.increment(); b1.update(20); // stop the bar b1.stop(); ``` -------------------------------- ### Install cli-progress Source: https://github.com/npkgz/cli-progress/blob/master/README.md Installs the cli-progress package using either Yarn or npm. ```bash $ yarn add cli-progress $ npm install cli-progress --save ``` -------------------------------- ### Custom Preset File Example Source: https://github.com/npkgz/cli-progress/blob/master/README.md An example of a custom preset file defining the format string using ansi-colors for red text and specifying Unicode characters for the progress bar. ```js const colors = require('ansi-colors'); module.exports = { format: colors.red(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit', barCompleteChar: '\u2588', barIncompleteChar: '\u2591' }; ``` -------------------------------- ### Basic cli-progress Usage Source: https://github.com/npkgz/cli-progress/blob/master/README.md Demonstrates the basic usage of cli-progress by creating a single progress bar, starting it, updating its value, and stopping it. ```javascript const cliProgress = require('cli-progress'); // create a new progress bar instance and use shades_classic theme const bar1 = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic); // start the progress bar with a total value of 200 and start value of 0 bar1.start(200, 0); // update the current value in your application.. bar1.update(100); // stop the progress bar bar1.stop(); ``` -------------------------------- ### CLI Progress - Synchronous Operation Example Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Demonstrates how to use the cli-progress package for synchronous operations. This example showcases the usage of `timeout` and `throttle time` options, which replaced the `interval` option. ```javascript const cliProgress = require('cli-progress'); // Create a new progress bar instance const progressBar = new cliProgress.SingleBar({ // options }, cliProgress.Presets.shades_classic); // Start the progress bar with a total value and initial value progressBar.start(200, 0); // Simulate a synchronous task let count = 0; const intervalId = setInterval(() => { count++; progressBar.increment(); if (count === 200) { clearInterval(intervalId); progressBar.stop(); } }, 100); // Simulate work every 100ms ``` -------------------------------- ### Single Bar Constructor and Methods Source: https://github.com/npkgz/cli-progress/blob/master/README.md Details the constructor for the SingleBar and its essential methods: start, update, increment, setTotal, stop, and updateETA. Explains their parameters and functionality. ```APIDOC SingleBar Constructor: Initialize a new Progress bar. An instance can be used **multiple** times! it's not required to re-create it! const = new cliProgress.SingleBar(options:object [, preset:object]); Methods: ::start(totalValue:int, startValue:int [, payload:object = {}]): Starts the progress bar and set the total and initial value. ::update([currentValue:int [, payload:object = {}]]): Sets the current progress value and optionally the payload. To update payload only, set currentValue to `null`. ::increment([delta:int [, payload:object = {}]]): Increases the current progress value by a specified amount (default +1). Update payload optionally. ::setTotal(totalValue:int): Sets the total progress value while progressbar is active. ::stop(): Stops the progress bar and go to next line. ::updateETA(): Force eta calculation update without altering the progress values. ``` -------------------------------- ### Multi Bar Mode Example Source: https://github.com/npkgz/cli-progress/blob/master/README.md Demonstrates how to use the MultiBar container to manage multiple progress bars simultaneously. Includes creating bars, updating them with custom data, and stopping the container. ```javascript const cliProgress = require('cli-progress'); // create new container const multibar = new cliProgress.MultiBar({ clearOnComplete: false, hideCursor: true, format: ' {bar} | {filename} | {value}/{total}', }, cliProgress.Presets.shades_grey); // add bars const b1 = multibar.create(200, 0); const b2 = multibar.create(1000, 0); // control bars b1.increment(); b2.update(20, {filename: "test1.txt"}); b1.update(20, {filename: "helloworld.txt"}); // stop all bars multibar.stop(); ``` -------------------------------- ### Multi Bar Start Event Source: https://github.com/npkgz/cli-progress/blob/master/docs/events.md This event is triggered after a bar element is created and its `start()` method is called within a MultiBar instance. It's useful for executing actions when a specific sub-bar begins. ```js const cliProgress = require('cli-progress'); const bar1 = new cliProgress.MultiBar(); bar1.on('start', () => { console.log('sub-bar element started'); }); ``` -------------------------------- ### Single Bar Start Event Source: https://github.com/npkgz/cli-progress/blob/master/docs/events.md This event is triggered after the `start()` method is called on a single progress bar instance. It allows you to execute custom logic when a single bar begins its progress. ```js const cliProgress = require('cli-progress'); const bar1 = new cliProgress.SingleBar(); bar1.on('start', () => { console.log('bar started'); }); ``` -------------------------------- ### Multibar Usage in Synchronous Context Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Provides examples and support for using multibars effectively within synchronous code execution flows. This clarifies how to manage multiple progress bars when the main thread is not performing asynchronous operations. ```javascript const cliProgress = require('cli-progress'); const multibar = new cliProgress.MultiBar(); for (let i = 0; i < 5; i++) { const bar = multibar.create(100, 0); for (let j = 0; j <= 100; j++) { // Simulate synchronous work let k = 0; while(k < 100000) k++; bar.update(j); } multibar.remove(bar); } ``` -------------------------------- ### CLI Progress - Non-TTY Environment Test Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md This example is designed to test the behavior of the cli-progress bar in non-interactive environments, such as when input streams are closed. It helps verify that the progress bar handles such scenarios gracefully without throwing errors. ```javascript const cliProgress = require('cli-progress'); // Create a new progress bar instance const progressBar = new cliProgress.SingleBar({ // options }, cliProgress.Presets.shades_classic); // Start the progress bar progressBar.start(100, 0); // Simulate some work let i = 0; while (i < 100) { i++; progressBar.update(i); // In a real non-tty scenario, this loop might be interrupted or run without a visible output. // The key is that `update()` should not throw an error. } progressBar.stop(); ``` -------------------------------- ### cli-progress v2.1.0 Enhancements Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Adds an `align` option for progress bar positioning, modifies ETA display for Infinity and NaN values, limits maximum ETA, and refactors ETA calculation. Also includes a bugfix for an example file. ```javascript Added: `align` option to change the position of the progress bar (left, center, right) - thanks to [sidneys on GitHub](https://github.com/npkgz/cli-progress/pull/22) #22 Changed: ETA value of type `Infinity` is displayed as **INF**, `NaN` as **NULL** - feature requested by [AxelTerizaki on GitHub](https://github.com/npkgz/cli-progress/issues/21) #21 Changed: Limited the maximum ETA value to `100000s` (**INF** is displayed in this case) Changed: ETA calculation moved to own scope Bugfix: example `example-notty.php` was broken ``` -------------------------------- ### Add custom bar characters in multibar.create() Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Introduces the ability to override default bar characters by providing custom options directly to the `multibar.create()` instance. This enhances flexibility in customizing the appearance of progress bars in multi-bar setups. ```javascript multibar.create(barOptions, { "barCompleteChar": "=", "barIncompleteChar": "-" }); ``` -------------------------------- ### Relative Progress Calculation Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md The `progressCalculationRelative` option, when enabled, uses the `startValue` as an offset for progress calculations. This allows for calculating absolute progress based on the difference between `total` and `startValue`, useful for processes that don't start from zero. ```javascript // Enable relative progress calculation const bar = new cliProgress.SingleBar({ progressCalculationRelative: true, startValue: 100, total: 1000 }); // Disable relative progress calculation (default behavior) const bar = new cliProgress.SingleBar({ progressCalculationRelative: false }); ``` -------------------------------- ### Multi Bar Constructor Source: https://github.com/npkgz/cli-progress/blob/master/README.md Explains the constructor for the MultiBar class, noting that it manages multiple single bars and uses its options/presets for each individual bar. ```APIDOC MultiBar Constructor: Initialize a new multiprogress container. Bars need to be added. The options/presets are used for each single bar! const = new cliProgress.MultiBar(options:object [, preset:object]); ``` -------------------------------- ### CLI Progress API Reference Source: https://github.com/npkgz/cli-progress/blob/master/README.md API documentation for managing multiple progress bars. Includes methods for creating, removing, and stopping bars, along with their parameters and return values. ```APIDOC ::create() Adds a new progress bar to the container and starts the bar. Returns regular `SingleBar` object which can be individually controlled. Additional `barOptions` can be passed directly to the [generic-bar](lib/generic-bar.js) to override the global options for a single bar instance. Parameters: totalValue:int - The total value the progress bar should reach. startValue:int - The initial value of the progress bar. payload:object = {} - Optional payload object. barOptions:object = {} - Optional object to override global bar options for this instance. Returns: SingleBar - An object representing the newly created and controlled progress bar. ::remove() Removes an existing bar from the multi progress container. Parameters: barInstance:object - The progress bar instance to remove. ::stop() Stops all progress bars managed by the container. ``` -------------------------------- ### cli-progress v1.4.0 Presets and Dependencies Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Introduces preset/theme support for different bar styles, adds the 'colors' dependency for colorized bars, and includes several new presets: 'legacy', 'shades-classic', 'shades-grey', and 'rect'. ```javascript Added: **Preset/Theme support**. Different bar-styles can be loaded from internal library (in addition to full customization) Added: Dependency **colors** for colorized progress bars Added: Preset `legacy` Added: Preset `shades-classic` Added: Preset `shades-grey` Added: Preset `rect` ``` -------------------------------- ### Custom Presets from File Source: https://github.com/npkgz/cli-progress/blob/master/README.md Defines a custom preset in a separate JavaScript file with specific format strings and characters, then applies it to the progress bar. ```js const myPreset = require('./myPreset.js'); const bar = new _progress.Bar({ barsize: 65 }, myPreset); ``` -------------------------------- ### Accessing Default Format Functions Source: https://github.com/npkgz/cli-progress/blob/master/README.md Demonstrates how to import and utilize default format functions like TimeFormat, ValueFormat, and BarFormat within custom formatters. ```js const {TimeFormat, ValueFormat, BarFormat, Formatter} = require('cli-progess').Format; ... ``` -------------------------------- ### Applying Styles from Presets Source: https://github.com/npkgz/cli-progress/blob/master/README.md Applies a predefined style preset (e.g., 'shades_grey') to the progress bar and adjusts the bar size and positioning. ```js const bar = new _progress.Bar({ barsize: 65, position: 'right' }, _progress.Presets.shades_grey); ``` -------------------------------- ### Setting Progress Bar Options Source: https://github.com/npkgz/cli-progress/blob/master/README.md Configures various aspects of the progress bar, including characters for completed and incomplete parts, FPS limit, output stream, bar size, and positioning. ```js const bar = new _progress.Bar({ barCompleteChar: '#', barIncompleteChar: '.', fps: 5, stream: process.stdout, barsize: 65, position: 'center' }); ``` -------------------------------- ### Handling Non-TTY Environments Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Addresses an issue where `multibar.create()` returned `undefined` in non-TTY environments (like CI/CD pipelines) when `noTTYOutput` was not explicitly enabled. This ensures predictable behavior in automated environments. ```javascript // Ensure output in non-TTY environments const bar = new cliProgress.SingleBar({ noTTYOutput: true }); ``` -------------------------------- ### cli-progress v1.5.1 Bugfixes Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Fixes two bugs: one preventing the progress bar from initializing to 0%, and another where ETA was NULL for (0/0) initialization. ```javascript Bugfix: Progressbar cannot be initialized to 0% - thanks to [erikkallen on GitHub](https://github.com/npkgz/cli-progress/pull/14) #13 Bugfix: ETA was **NULL** in case the progress bar is initialized with (0/0) ``` -------------------------------- ### cli-progress v3.1.0 Features Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Introduces 'notty' support for interval/schedule-based output and `stopOnComplete` support within `MultiBar`. Also includes changes to `MultiBar`'s initial throttle time and a bugfix for option precedence. ```javascript Added: notty support (interval/schedule based output) - feature requested [on GitHub](https://github.com/npkgz/cli-progress/issues/25) Added: `stopOnComplete` support within `MultiBar` - thanks to [Nox-404 on GitHub](https://github.com/npkgz/cli-progress/pull/35) Changed: initial throttel time of `MultiBar` is controlled by `fps` option instead of static `500ms` value Bugfix: provided option didn't take precedence over the preset as in v2 - thanks to [AxelTerizaki on GitHub](https://github.com/npkgz/cli-progress/issues/37) #37 ``` -------------------------------- ### cli-progress v3.0.0 Major Changes Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Introduces multi-progressbar support, a `synchronousUpdate` option, project restructuring into multiple classes, and changes the default output stream to `stdout`. ```javascript Added: multi-progressbar support - feature requested [on GitHub](https://github.com/npkgz/cli-progress/issues/26) Added: option `synchronousUpdate` to control the synchronized redraw during `update()` call (default=`true`) Changed: project split into multiple classes Changed: default cli progress output is written to `stdout` instead of `stderr` ``` -------------------------------- ### cli-progress v1.5.0 Zero Initialization Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Allows 0 values for total and progress initialization, a feature requested by users. ```javascript Added: **0** values for total/progress initialization are allowed - feature requested by [jfmmm on GitHub](https://github.com/npkgz/cli-progress/issues/11) #11 ``` -------------------------------- ### Exported Standard Formatter and Format Helper Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Standard formatter and format helper functions are now exported, allowing users to easily access and utilize the library's built-in formatting capabilities for custom progress bar displays. ```javascript const cliProgress = require('cli-progress'); const formatHelper = cliProgress.FormatHelper; const formattedTime = formatHelper.formatTime(125000); console.log(formattedTime); // Output: 34:56 ``` -------------------------------- ### cli-progress v3.3.0 Feature Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Introduces the ability to pass custom formatters as callbacks via the `options.format` property. Also includes a performance enhancement by replacing static placeholder code with generic regex. ```javascript Added: option to pass custom formatters as callback via `options.format` Changed: replaced static placeholder code with generic regex (performance enhancement) ``` -------------------------------- ### cli-progress v3.2.0 Options Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Adds the `emptyOnZero` option, allowing bars with a total of zero to be displayed as empty instead of full. Also includes a bugfix for multi-bars related to cursor save/restore calls. ```javascript Added: `emptyOnZero` option to display total:0 bars as empty, not full - thanks to [nickcmaynard on GitHub](https://github.com/npkgz/cli-progress/pull/42) Bugfix: removed cursor save/restore calls for multibars - clearOnComplete might not work on all environments - thanks to [sayem314 onGitHub](https://github.com/npkgz/cli-progress/issues/40) ``` -------------------------------- ### Passing Bar Options to multibar.create() Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Allows passing specific bar options as overrides when creating new bars within a multibar instance. This enables granular control over individual bar appearances and behaviors within a group. ```javascript const multibar = new cliProgress.MultiBar(); const bar1 = multibar.create(100, 50, { format: 'Bar 1 | {bar} | {percentage}%' }); const bar2 = multibar.create(200, 150, { format: 'Bar 2 | {bar} | {percentage}%' }); ``` -------------------------------- ### Custom Format String Source: https://github.com/npkgz/cli-progress/blob/master/README.md Defines a custom format string for the progress bar, specifying elements like the bar, percentage, ETA, and current value. ```js const opt = { format: 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}' } ``` -------------------------------- ### Create and Control Single Progress Bar Source: https://github.com/npkgz/cli-progress/blob/master/README.md Adds a new progress bar to the container and returns a `SingleBar` object for individual control. Accepts optional `barOptions` to customize appearance, overriding global settings for that specific bar. ```javascript const = .create(totalValue:int, startValue:int [, payload:object = {} [, barOptions:object = {}]]); ``` -------------------------------- ### Custom Payload Tokens Source: https://github.com/npkgz/cli-progress/blob/master/README.md Initializes a progress bar with a custom token 'speed' in the format string and updates its value during operation. Payload keys must match \w+ regex. ```js const bar = new _progress.Bar({ format: 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit' }); // initialize the bar - set payload token "speed" with the default value "N/A" bar.start(200, 0, { speed: "N/A" }); // ... // update bar value. set custom token "speed" to 125 bar.update(5, { speed: '125' }); // process finished bar.stop(); ``` -------------------------------- ### Custom Format Functions Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Provides support for custom formatter functions for time, bar appearance, and values. This allows for highly customized progress bar displays tailored to specific needs. ```javascript const customTime = (time) => `~${time} left`; const customFormat = (progress, total, bar) => `Progress: ${bar.formattedTime} | ${progress}/${total}`; const bar = new cliProgress.SingleBar({ formatTime: customTime, format: customFormat }); ``` -------------------------------- ### Logging with cli-progress Source: https://github.com/npkgz/cli-progress/blob/master/README.md Outputs buffered content on top of the multi-bars during operation. A newline at the end of the logged message is required. ```js instance.log("Hello World\n"); ``` -------------------------------- ### Log Method for Multibar Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md A new `log()` convenience method is added to the multibar. This method allows for custom logging output to appear directly above the progress bars, facilitating better in-process feedback without interfering with the bars themselves. ```javascript multibar.log('Processing item 5...'); ``` -------------------------------- ### cli-progress v2.1.1 Bugfix Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Fixes an issue where the preset object was being altered by options. ```javascript Bugifx: preset object got altered by options - thanks to [rvalitov on GitHub](https://github.com/npkgz/cli-progress/issues/27) #27 ``` -------------------------------- ### cli-progress v2.0.0 Node.js Upgrade Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Requires Node.js 4 or higher. Introduces `linewrap` option, uses native ES2015 class syntax, renames the entry file, encapsulates terminal interactions, restores terminal settings, and fixes bugs related to escape sequences and line wrapping. ```javascript Upgrade is possible without any code modifications! requires **node.js 4** Added: option `linewrap` to disable terminal line wrapping (default) Changed: requires **node.js >= 4** Changed: Native ES2015 class syntax Changed: renamed application entry file to `cli-progress.js` Changed: low-level terminal interactions are encapsulated within `Terminal` class Changed: terminal/cursor settings are restored after progress bar stopped Bugfix: used hex ascii escape sequences instaed of octals to avoid javascript errors in recent nodejs version Bugfix: disabled line wrapping by default to avoid multiple line breaks on small terminals (cut on the right) - reported by [puppeteer701 on GitHub](https://github.com/npkgz/cli-progress/issues/20) #20 ``` -------------------------------- ### EventEmitter Support Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Integrates support for Node.js's `EventEmitter`, allowing progress bars to emit events. This enables more sophisticated control and interaction with the progress bars, such as reacting to completion or state changes. ```javascript const cliProgress = require('cli-progress'); const _progress = new cliProgress.SingleBar(); _progress.on('progress', (progress) => { console.log(`Current progress: ${progress}`); }); ``` -------------------------------- ### Custom Formatter Function Source: https://github.com/npkgz/cli-progress/blob/master/README.md Implements a custom formatter function to dynamically control the progress bar's appearance based on progress and payload data. It handles color changes for completion. ```js function formatter(options, params, payload){ // bar grows dynamically by current progress - no whitespaces are added const bar = options.barCompleteString.substr(0, Math.round(params.progress*options.barsize)); // end value reached ? // change color to green when finished if (params.value >= params.total){ return '# ' + colors.grey(payload.task) + ' ' + colors.green(params.value + '/' + params.total) + ' --[' + bar + ']-- '; }else{ return '# ' + payload.task + ' ' + colors.yellow(params.value + '/' + params.total) + ' --[' + bar + ']-- '; } } const opt = { format: formatter } ``` -------------------------------- ### cli-progress v1.8.0 Method Added Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Introduces the `setTotal()` method, allowing manipulation of the total value of a running progress bar. ```javascript Added: method `setTotal()` to manipulate the total value within running progress-bar - feature requested by [ReggaePanda on GitHub](https://github.com/npkgz/cli-progress/issues/19) #19 Changed: moved example file to `examples/` directory ``` -------------------------------- ### Asynchronous ETA Update Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Introduces optional asynchronous ETA (Estimated Time of Arrival) updates for long-running processes. This feature allows for more accurate ETA calculations without blocking the main thread, improving responsiveness. ```javascript // Example usage (conceptual) const bar = new cliProgress.SingleBar({ asynchronousUpdate: true }); // ... process ... // Trigger ETA calculation without progress update bar.updateETA(); ``` -------------------------------- ### Auto-Padding Option Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md The `autoPadding` option ensures that values within the progress bar display have a fixed size by adding padding. This creates a more uniform and visually appealing output, especially when values change dynamically. ```javascript const bar = new cliProgress.SingleBar({ autoPadding: true, padding: 5 }); ``` -------------------------------- ### cli-progress v1.6.1 Bugfix Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Fixes a bug where the `roundTo` parameter was not correctly set for `elapsedTime` calculation, leading to raw float values in formatted time strings. ```javascript Bugfix: `roundTo` parameter was not set for `elapsedTime` calculation which caused raw float values within formatted time strings - thanks to [rekinyz on GitHub](https://github.com/npkgz/cli-progress/pull/16) #16 ``` -------------------------------- ### cli-progress v3.3.1 Bugfix Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Addresses a bug where synchronous updates could cause unexpected behavior in multi-bar configurations, limiting the fix to single bars. ```javascript Bugifx: synchronous update may cause unexpected behaviour on multibars - limited to single bars Changed: renamed internal eta `push()` method to `update()` Changed: moved internal eta calculation call into `update()` ``` -------------------------------- ### Removed 'colors' Dependency Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md The 'colors' dependency has been removed due to issues with its maintainer. This change aims to improve stability and avoid potential problems associated with external dependencies. ```javascript // No direct code change required, but ensures compatibility with ansi-colors // Example using ansi-colors for styling: const colors = require('ansi-colors'); console.log(colors.green('Processing complete!')); ``` -------------------------------- ### Bar Glue Option Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md The `barGlue` option allows inserting ASCII escape sequences, such as color codes, between the complete and incomplete parts of the progress bar. This enables advanced visual styling and colorization of the progress bar itself. ```javascript const bar = new cliProgress.SingleBar({ barGlue: '\u001b[32m' }); // Green color ``` -------------------------------- ### Graceful Exit Option Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md The `gracefulExit` option, enabled by default, ensures that progress bars are properly stopped and cursor settings are restored when the process receives `SIGINT` or `SIGTERM` signals. This prevents abrupt termination and potential terminal corruption. ```javascript // Enable graceful exit (default behavior) const bar = new cliProgress.SingleBar({ gracefulExit: true }); // Disable graceful exit const bar = new cliProgress.SingleBar({ gracefulExit: false }); ``` -------------------------------- ### Payload Argument for increment() and update() Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Enhances the `increment()` and `update()` methods by allowing a payload to be passed as the first argument. For `increment()`, this payload implicitly sets the delta to 1. For `update()`, it allows passing payload data without necessarily changing the bar's value. ```javascript // Increment with implicit delta of 1 and payload bar.increment({ task: 'downloading file' }); // Update bar value and pass payload bar.update(50, { status: 'processing' }); // Update only payload without changing bar value bar.update(null, { status: 'idle' }); ``` -------------------------------- ### Single and Multi Bar Events Source: https://github.com/npkgz/cli-progress/blob/master/docs/events.md cli-progress emits several events during the lifecycle of progress bars. These include 'stop' for when a bar finishes, 'redraw-pre' and 'redraw-post' for pre and post rendering updates, and 'update-pre' and 'update-post' for updates before and after terminal output. ```js const cliProgress = require('cli-progress'); // For SingleBar: const bar1 = new cliProgress.SingleBar(); bar1.on('stop', () => { /* ... */ }); bar1.on('redraw-pre', () => { /* ... */ }); bar1.on('redraw-post', () => { /* ... */ }); // For MultiBar: const multiBar = new cliProgress.MultiBar(); multiBar.on('stop', () => { /* ... */ }); multiBar.on('stop-pre-clear', () => { /* ... */ }); multiBar.on('update-pre', () => { /* ... */ }); multiBar.on('redraw-pre', () => { /* ... */ }); multiBar.on('redraw-post', () => { /* ... */ }); multiBar.on('update-post', () => { /* ... */ }); ``` -------------------------------- ### cli-progress v1.6.0 Custom Tokens Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Introduces additional payload data that can be used as custom tokens within the progress bar. ```javascript Added: Additional payload data which can be used as **custom-tokens** within the bar - thanks to [tobiasps on GitHub](https://github.com/npkgz/cli-progress/pull/15) #15 ``` -------------------------------- ### cli-progress v1.7.0 Payload Argument Source: https://github.com/npkgz/cli-progress/blob/master/CHANGES.md Adds a payload argument to the `increment()` method, allowing for additional data to be passed. ```javascript Added: payload argument to `increment()` - feature requested by [dsego on GitHub](https://github.com/npkgz/cli-progress/issues/18) #18 ``` -------------------------------- ### Stop All Progress Bars Source: https://github.com/npkgz/cli-progress/blob/master/README.md Stops all currently active progress bars managed by the container. ```javascript .stop(); ``` -------------------------------- ### Remove Progress Bar Source: https://github.com/npkgz/cli-progress/blob/master/README.md Removes a specific progress bar instance from the multi-progress container. ```javascript .remove(:object); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.