Skip to content
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

Merged
merged 1 commit into from
Apr 15, 2022
Merged

Conversation

rgreinho
Copy link
Owner

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

@rgreinho rgreinho self-assigned this Apr 13, 2022
@rgreinho rgreinho force-pushed the issues/5/bar-opt branch 9 times, most recently from 71cda9a to d312bbf Compare April 14, 2022 14:20
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
Comment on lines +334 to +346
"{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 = "█▇▆▅▄▃▂▁ ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks clean!

Copy link
Owner Author

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 {
Copy link
Contributor

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

Copy link
Contributor

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(); 

let style = self.to_progress_style();

Copy link
Owner Author

@rgreinho rgreinho Apr 15, 2022

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.

@rgreinho rgreinho merged commit f99a0ef into main Apr 15, 2022
@kodiakhq kodiakhq bot deleted the issues/5/bar-opt branch April 15, 2022 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make progress bars optional Make progress bars configurable
2 participants