-
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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6378 +/- ##
==========================================
- Coverage 96.24% 96.18% -0.07%
==========================================
Files 555 557 +2
Lines 42047 42151 +104
Branches 6369 6375 +6
==========================================
+ Hits 40470 40542 +72
- Misses 1537 1569 +32
Partials 40 40 ☔ View full report in Codecov by Sentry. |
* The character to fill the progress bar up with as it makes progress. | ||
* @default {'#'} | ||
*/ | ||
fullChar?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fillChar
?
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)}]` }) |
* The offset size of the input if progress is resuming part way through. | ||
* @default {0} | ||
*/ | ||
currentSize?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's call it value
like in progress HTMLElement?
/** | ||
* The total size expected to receive. | ||
*/ | ||
totalSize: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's call it max
like in progress HTMLElement?
* Whether the progress bar should be removed after completion. | ||
* @default {false} | ||
*/ | ||
clearBar?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's call it just clear
as in
Line 24 in 3b75ee7
clear?: boolean; |
* completion. | ||
* @default {true} | ||
*/ | ||
preventClose?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think options should be formulated positively rather than negatively, something like keepAlive
, keepStreamOpen
, closeStream
or closeStreamWhenCompleted
.
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: