console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.21k stars 238 forks source link

[feature request] adding `{percent_precise}` style key #628

Closed OmarTawfik closed 4 months ago

OmarTawfik commented 4 months ago

The existing {percent} is rendered as an integer, which means it is not very useful for large data sets, as it rarely changes.

I suggest adding a new {percent_precise} (a non-breaking change?) that would render it with additional precision. For example 3 fraction digits, as demonstrated by the test added here.

An earlier proposal to add precision to variables was rejected (#552), and AFAIK, there is no way to customize this without taking over rendering. I think this proposal would work well with existing variables like elapsed_precise, eta_precise.

Thanks for considering!

chris-laplante commented 4 months ago

Seems okay. @chris-laplante what do you think?

(Note that this can be done using a custom ProgressTracker implementation.)

I think it's a common enough use case that we shouldn't force people to use ProgressTracker. So +1 from me.

OmarTawfik commented 4 months ago

@djc @chris-laplante Thanks for looking into this! I wonder when do new released get pushed to crates.io?

djc commented 4 months ago

More or less by request: https://github.com/console-rs/indicatif/pull/629.

OmarTawfik commented 4 months ago

@djc looks like the deployment failed (job) 😞 One test (style::tests::wide_element_style) randomly failed. Not sure why, although it succeeded in other jobs in the matrix, and with the same toolchain on the previous commit. I don't have permissions to rerun the job, but please let me know if I can debug/help with anything otherwise to unblock publishing.

chris-laplante commented 4 months ago

@djc looks like the deployment failed (job) 😞 One test (style::tests::wide_element_style) randomly failed. Not sure why, although it succeeded in other jobs in the matrix, and with the same toolchain on the previous commit. I don't have permissions to rerun the job, but please let me know if I can debug/help with anything otherwise to unblock publishing.

It is unrelated to your changes - it failed a few days ago as well: https://github.com/console-rs/indicatif/issues/631