Skip to content

Commit

Permalink
Merge pull request #4 from maartenvr98/master
Browse files Browse the repository at this point in the history
Support for custom options
  • Loading branch information
RahulDey12 committed Feb 15, 2022
2 parents 30efeb2 + aa1d27d commit ca738e7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/LaravelConsoleSpinnerServiceProvider.php
Expand Up @@ -22,11 +22,18 @@ function (int $max = 0) {

Command::macro(
'withSpinner',
function ($totalSteps, \Closure $callback, string $message = '') {
function ($totalSteps, \Closure $callback, string $message = '', array $options = []) {
$spinner = $this->spinner(
is_iterable($totalSteps) ? count($totalSteps) : $totalSteps
);
$spinner->setMessage($message);

// Set more options
foreach($options as $option => $value) {
$method = 'set' . ucfirst($option);
$spinner->{$method}($value);
}

$spinner->start();

if (is_iterable($totalSteps)) {
Expand Down

0 comments on commit ca738e7

Please sign in to comment.