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

eta_formatted and duration_formatted number padding #60

Closed
lain-d opened this issue Jan 21, 2020 · 5 comments
Closed

eta_formatted and duration_formatted number padding #60

lain-d opened this issue Jan 21, 2020 · 5 comments

Comments

@lain-d
Copy link

lain-d commented Jan 21, 2020

Would be great for the eta_formatted and duration_formatted values to be padded. Without padding it causes a lot of jumping of the bars when displaying single digit numbers.

@AndiDittrich
Copy link
Member

not as default format - you can use a custom formatter so solve the issue.

additionally i can may add custom filter functions for all placeholder

@lain-d
Copy link
Author

lain-d commented Jan 21, 2020

Hi Andi, thanks for your response! I'm able to pad the percentage by using a simple function in the format

('00'+'{percentage}').slice(-2);

However, ETA_formatted and duration_formated come in as full string (like 24m5s or 5m45s, etc). And without a complex regex it would be difficult to format them with number pads.

An option when invoking a new cli-bar to optionally set a number of digits to pad numbers for formatted outputs would be amazing. If you accept pull requests on this great library I would be happy to try to help when I have some time.

@AndiDittrich
Copy link
Member

It is quite easy to implement but i'm looking for a more generic solution (especially it should not break the existing behaviour)

@AndiDittrich
Copy link
Member

i've just added two options to the master branch:

  • autopadding (type: boolean) - add padding chars to formatted time and percentage to force fixed width (default: false) - Note: handled standard format functions!
  • autopaddingChar (type: string) - the character sequence used for autopadding (default: " ") - Note: due to performance optimizations this value requies a length of 3 identical chars

additionally, you can use custom element format callbacks to override the default rendering:

  • formatBar (type: function) - a custom bar formatter function which renders the bar-element (default: format-bar.js)
  • formatTime (type: function) - a custom timer formatter function which renders the formatted time elements like eta_formatted and duration-formatted (default: format-time.js)
  • formatValue (type: function) - a custom value formatter function which renders all other values (default: format-value.js)

@lain-d
Copy link
Author

lain-d commented Jan 23, 2020

Amazing Andi! I'll try it out. I'm using your library for a CLI batch video converter, and it's working great!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants