paul / progress_bar

A Ruby terminal progress_bar
Do What The F*ck You Want To Public License
623 stars 49 forks source link

Major Feature: Add in custom characters, colour and logging #43

Closed TRex22 closed 5 years ago

TRex22 commented 5 years ago

What does this PR do?

Why do I want to merge these changes?

I found this library by chance - and it worked better than a few others for my use case. I know in the readme it says its feature complete but using it actively I found that not being able to change the characters or properly log to STDOUT greatly diminished the usefulness of the library.

In order to add these features I found I needed to change the main interface - there were other options available to me but I felt this was the cleanest solution

paul commented 5 years ago

Hi @TRex22,

Thanks for taking the time to submit a PR! Lots of good ideas here. Some of them, though, I'm not OK with. Do you mind making a few separate PRs for this instead? I would accept PRs that add support for colors and for changing the bar character. I'm also not sure what you mean by "the ability to log above the progress_bar without affecting it", could you provide an example?

However, I don't want to change the primary interface. 99% of the time, the way ProgressBar is used is to take a single argument which is the size of the incrementing counter, and I don't want that to change.

bar = ProgressBar.new(100)
xs.each { bar.increment! }

I think we can still accomplish what you want with keyword args, though. Something like this?

ProgressBar.new(42, color: :blue)
ProgressBar.new(314, bar: "█", delimiters: "||")

Then the initializer looks like this:

def initialize(max, *meters, color: nil, bar: "#", delimiters: "[]")

You can also allow colour: if you like, but Ruby usually prefers the American spellings. I think it should take the ANSI color name instead of (or in addition to) a number.

TRex22 commented 5 years ago

Cool perfect. Ill make the changes as soon as I can.

TRex22 commented 5 years ago

@paul what is your opinion on bumping the version?

paul commented 5 years ago

@TRex22 If you make the changes additive in the initializer like I mocked up, then we can just do a new minor release, no reason to bump the major version.