wp-cli / php-cli-tools

A collection of tools to help with PHP command line utilities
MIT License
673 stars 118 forks source link

adding optional msg parameter to \cli\Progress\Bar::tick() #126

Closed lf-jeremy closed 6 years ago

lf-jeremy commented 6 years ago

As discussed in #125

The tick method of \cli\Notify::tick() is augmented in its grandchild class, \cli\Progress\Bar to have an optional second parameter which updates its _message property. As items are processed, the message may be optionally changed to reflect the nature of the work being performed.

The current behavior of the progress bar suppresses any output until the first tick occurs. In use cases where the developer wishes to display the initial message and then alter it during the first tick, they should manually call the public display() method of the progress bar before work is performed and the tick occurs.

The use case of displaying a message describing work about to be performed would be better served by supplementing this updated tick() method with a setter for the _message property whereby the message is manually changed before work is performed, then the tick is used to increment progress separately.

schlessera commented 6 years ago

Thanks for the pull request!

lf-jeremy commented 6 years ago

Thanks for your involvement, @schlessera. This probably calls for updating the progress bar documentation as well. Appreciate the collaboration!