Closed SteelAlloy closed 4 years ago
I have changed my code.
interface renderOptions {
title?: string,
total?: number,
complete?: string,
incomplete?: string,
}
render(completed: number, options? renderOptions): void;
exmaple
import ProgressBar from "https://deno.land/x/progress@v1.0.0/mod.ts";
const total = 100;
const progress = new ProgressBar({
total,
display: ':percent :bar :time :completed/:total :title'
});
let completed = 0;
function run() {
if (completed <= total) {
progress.render(completed++, {
title: `CUSTOM TEXT, value: ${Math.random().toFixed(3)}`
});
setTimeout(function () {
run();
}, 50)
}
}
run();
Thank you very much, that's exactly what I needed! I can display the files that are being processed.
I just have a little problem, the titles are of variable length and the bar collapses at times. Is there a way to fix this or is it necessary to keep it from spilling over?
EDIT:
When I display accents with progress.console
, they are not displayed correctly. I think this is Deno's fault.
With `console.log':
barWidth = Math.min(this.width, ttyWith) - titleWith - percentWidth -timeWidth - (completed/total)Width; Too many settings will cause too complicated. You can modify it to suit your program on the current basis. You can also submit a pull request if you have a good idea.
progress.console use Deno.writeAllSync, I plan to submit a pull request to deno to fix it.
I think it will be better when the TTY columns will be supported. Thank you!
process.console bug, can see this issue:
This module is very good, it gives me what I need.
But I was wondering if it would be possible to display text at each rendering, i.e. to inform about what's going on. For example, the current value of a variable or the file that is being processed.
Either on the right side of the bar: NOTE: The bars are one on top of the other but it's just to show the look at each render, the bar is of course erased each time.
Or above the bar and just like it, the text would be erased at each rendering:
I'm asking this because I don't want to pollute the console with millions of messages that could very well be integrated with the bar.