Skip to content

Conversation

@robinmoisson
Copy link
Contributor

@robinmoisson robinmoisson commented Sep 2, 2024

The withProgressBar method in the InteractsWithIO console trait can be used to iterate over an iterable while displaying a progress bar in the console, in essence adding a progress bar to a foreach loop.

Currently the callback only takes the $value of each step, which means it can't be used as easily if we want to unpack both $key and $value in each step.

This PR adds $key to the callback called in the foreach, transforming it from $callback($value, $bar) to $callback($value, $bar, $key), with arguments in that order to keep backward compatibility ($bar is the ProgressBar instance).


I'm not sure if it's really necessary to update the progress bar docs to show that extra parameter, but if you think it'd be better I'd be happy to.

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

Labels

None yet

2 participants