Render multiple progress bars
shixiaobao17145 opened this issue · 2 comments
shixiaobao17145 commented
Thanks for making this library.
Sometimes we want to show multiple bars at a time, for example, if we program to download files, we want to show their progress on the console together. How to make that happen with this library? Thanks!
fuxingZhang commented
Good idea! I need some time to think.
fuxingZhang commented
already updated
import { MultiProgressBar } from "https://deno.land/x/progress@v1.2.3/mod.ts";
const title = 'download files';
const total = 100;
const bars = new MultiProgressBar({
title,
// clear: true,
complete: '=',
incomplete: '-',
display: '[:bar] :text :percent :time :completed/:total'
});
let completed1 = 0;
let completed2 = 0;
function downloading() {
if (completed1 <= total || completed2 <= total) {
completed1 += 1
completed2 += 2
bars.render([
{ completed: completed1, total, text: "file1" },
{ completed: completed2, total, text: "file2" }
]);
setTimeout(function () {
downloading();
}, 100)
}
}
downloading();
You can also change the style of the progress bar
bars.render([
{
completed: completed1,
total,
text: "file1",
complete: "*",
incomplete: ".",
},
{ completed: completed2, total, text: "file2" },
]);