There is an existing example that updates progress bar in place: https://github.com/nathanpeck/clui/blob/master/examples/progress.js (60 lines in total)
There is much simpler example directly in the readme: https://github.com/nathanpeck/clui/blob/master/README.md (4 lines only)
var clui = require('clui');
var Progress = clui.Progress;
var thisProgressBar = new Progress(20);
console.log(thisProgressBar.update(10, 30));
So I've added setInterval so that it updates the progress. I've also added line to clear the console and new console.log with each interval:
var clui = require('clui');
var Progress = clui.Progress;
var value = 50;
var thisProgressBar = new Progress(20);
console.log(thisProgressBar.update(value, 100));
var intervalId = setInterval(function() {
value++;
// console.log("Updated value: " + value);
process.stdout.write('\033c'); // clearing the console
console.log(thisProgressBar.update(value, 100));
if (value === 100) {
clearInterval(intervalId);
}
}, 500)
In the example with countdown spinner I don't have clear the console and do console.log, see example: https://github.com/nathanpeck/clui/blob/master/README.md#spinnerstatustext
Ideally I would like to do just thisProgressBar.update(value, 100) and the progress bar should be updated in places easily...
(without clearing the existing console - I may have so many other progress bars and elements running)
There is an existing example that updates progress bar in place: https://github.com/nathanpeck/clui/blob/master/examples/progress.js (60 lines in total)
There is much simpler example directly in the readme: https://github.com/nathanpeck/clui/blob/master/README.md (4 lines only)
So I've added
setIntervalso that it updates the progress. I've also added line toclearthe console and newconsole.logwith each interval:In the example with countdown spinner I don't have
clearthe console and doconsole.log, see example: https://github.com/nathanpeck/clui/blob/master/README.md#spinnerstatustextIdeally I would like to do just
thisProgressBar.update(value, 100)and the progress bar should be updated in places easily...(without clearing the existing console - I may have so many other progress bars and elements running)