Skip to content

Commit

Permalink
added multicolor bar example
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiDittrich committed Jan 25, 2020
1 parent 84cdc81 commit d153a8d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/example-colorized.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const _progress = require('../cli-progress');

// create a new progress bar with preset
const bar = new _progress.Bar({
// green bar, reset styles after bar element
format: ' >> [\u001b[32m{bar}\u001b[0m] {percentage}% | ETA: {eta}s | {value}/{total}',

// same chars for bar elements, just separated by colors
barCompleteChar: '#',
barIncompleteChar: '#',

// change color to yellow between bar complete/incomplete -> incomplete becomes yellow
barGlue: '\u001b[33m'
});
bar.start(200, 0);

// random value 1..200
bar.update(Math.floor((Math.random() * 200) + 1));
bar.stop();

0 comments on commit d153a8d

Please sign in to comment.