clint icon indicating copy to clipboard operation
clint copied to clipboard

Add format_str parameter for progress bar and mill

Open RazerM opened this issue 9 years ago • 3 comments

I wanted to add a way to customise the progress bar output, so implemented a parameter to pass a format string.

The details are in the commit message, but is shown here with formatting:


progress.Bar, progress.bar, and progress.mill have a new format_str parameter.

Named fields are used to facilitate the change. Using the new syntax, the original formats could be represented as below:

'{label}[{bar}] {completed}/{total} - {eta}'
'{label} {mill} {completed}/{total}'

str.format() fails gracefully when named fields aren't present in the string, allowing a given part of the string to be omitted. On the other hand, incorrect field names cause a KeyError, preventing user error.

Note that when format_str=None, the old templates are used so that any code that modifies progress.BAR_TEMPLATE, for example, is not affected by the change.

Also, the format_str parameter does not require \r at the end, it is appended automatically.

RazerM avatar Jan 24 '15 00:01 RazerM

Yes please. Is there anything preventing this from being merged (other than the conflict in AUTHORS that is trivial to resolve)?

0xallie avatar Aug 12 '17 09:08 0xallie

Redundant merge commit much. :P You should have used git pull --rebase.

0xallie avatar Aug 17 '17 17:08 0xallie

I clicked the resolve conflict button in the UI since you mentioned it. I'll bother rebasing if it a) looks like it'll be merged and b) won't be squashed…

RazerM avatar Aug 17 '17 17:08 RazerM