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

Style position and length with commas #339

Closed
dabreegster opened this issue Dec 30, 2021 · 1 comment
Closed

Style position and length with commas #339

dabreegster opened this issue Dec 30, 2021 · 1 comment

Comments

@dabreegster
Copy link
Contributor

This is a fantastic crate, thanks so much for building and maintaining it!

I'm currently including {pos}/{len} in my template string, but for huge data, something like "33857009/42672348" isn't terribly readable to me. I'd like to style it as "33,857,009/42,672,348". I'm proposing:

  1. Adding a HumanCount structure along the lines of HumanBytes
  2. Adding human_pos and human_len as template keys, in https://github.com/mitsuhiko/indicatif/blob/0626585b006e9ba11df065c0d0d3df275d202257/src/style.rs#L270

Very open to better names than these. To actually do the formatting could be a bit tricky, since there are different styles based on locale: https://docs.microsoft.com/en-us/globalization/locale/number-formatting.

Option 1) Just hardcode the use of US-style commas.
2) Use num_format and allow the user to explicitly override a Locale, possibly as a new set_locale method on ProgressBar
3) Use num_format and enable the with-system-locale feature
4) Use num_format, let people specify the locale in the string (like {len:en}), and have some kind of parsing to get to the Locale enum

Any preferences here? I'm happy to send a PR; the hard part is making these decisions. Thanks!

@djc
Copy link
Collaborator

djc commented Dec 30, 2021

HumanCount, human_len and human_pos sound good to me. Let punt on the localization question and stick to US-style formatting for now. PR welcome!

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

No branches or pull requests

2 participants