-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): Intro createProgressBar()
& new ProgressBarStream()
#6378
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6378 +/- ##
==========================================
+ Coverage 96.23% 96.24% +0.01%
==========================================
Files 556 558 +2
Lines 42065 42181 +116
Branches 6371 6379 +8
==========================================
+ Hits 40481 40597 +116
Misses 1544 1544
Partials 40 40 ☔ View full report in Codecov by Sentry. |
I agree that showing the progress of byte number count is a common task. But can we also support the progress of abstract counter, like number of packages, number of files, etc. |
Should the amount just offer to display no unit for that instance or ask for custom unit? |
I think It'll probably be confusing to just omit the unit. If How about having |
That could work. I was more thinking of offering a custom unit option and if set then the rate calculation would be 1 so they could see something like |
Maybe we should add a Something according to: import { format as formatDuration } from "@std/fmt/duration.ts"
import { format as formatBytes } from "@std/fmt/bytes.ts"
new ProgressBarStream(Deno.stdout.writable, { formatter: ({ time, progressBar, value, max }) => `[${formatDuration(time)}] ${progressBar} [${formatBytes(value)}/${formatBytes(max)}]` }) |
Instead of having a punch of boolean options about what to and not to include, we now have a default format or a fmt function that can be set to customise the format of the progress bar.
I added this and a bit more to it, making it optional as I doubt everyone who wants a progress bar wants to go through the effort of styling it. |
Closes: #6374
This pull request introduces a function called
createProgressBar
and a class calledProgressBarStream
. They write and update a progress to the writable stream passed to them. The methods have quite a bit of configurability.Tests are yet to be created. Not sure exactly how to create tests to validate behaviour.
Example
stdout: