-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add the ability to customize the progress bars #24
Conversation
71cda9a
to
d312bbf
Compare
d312bbf
to
8f5b398
Compare
"{bar:40.green/black} {bytes:>11.green}/{total_bytes:<11.green} {bytes_per_sec:>13.red} eta {eta:.blue}"; | ||
/// Use increasing quarter blocks as progress characters: `"█▛▌▖ "`. | ||
pub const CHARS_BLOCKY: &'static str = "█▛▌▖ "; | ||
/// Use fade-in blocks as progress characters: `"█▓▒░ "`. | ||
pub const CHARS_FADE_IN: &'static str = "█▓▒░ "; | ||
/// Use fine blocks as progress characters: `"█▉▊▋▌▍▎▏ "`. | ||
pub const CHARS_FINE: &'static str = "█▉▊▋▌▍▎▏ "; | ||
/// Use a line as progress characters: `"━╾─"`. | ||
pub const CHARS_LINE: &'static str = "━╾╴─"; | ||
/// Use rough blocks as progress characters: `"█ "`. | ||
pub const CHARS_ROUGH: &'static str = "█ "; | ||
/// Use increasing height blocks as progress characters: `"█▇▆▅▄▃▂▁ "`. | ||
pub const CHARS_VERTICAL: &'static str = "█▇▆▅▄▃▂▁ "; |
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.
looks clean!
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.
🤗
} | ||
|
||
/// Create a [`ProgressStyle`] based on the provided options. | ||
pub fn to_progress_style(self) -> ProgressStyle { |
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.
You could probably do this as impl From<ProgressBarOpts> for ProgressStyle
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.
- let style = self.to_progress_style();
+ let style = self.into();
Line 383 in 8f5b398
let style = self.to_progress_style(); |
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 thought of it, but then, I thought that impl From<T>
implies a conversion. However here we are using some values from the options to build a ProgressStyle. Therefore It did not seem very idiomatic to me.
But maybe I was thinking about it too much. If you still don't see any problem after reading this, I'll implement the From
trait.
Gives the user the ability to customize the visual aspects of the main
and/or the child progress bars. The bars can now also be disabled if
needed.
Fixes #5
Fixes #6