Skip to content

Commit

Permalink
Interact support for cc bin (drush-ops#4540)
Browse files Browse the repository at this point in the history
* Interact support for cc bin

* newline
  • Loading branch information
weitzman committed Aug 26, 2020
1 parent 22b2965 commit cc3035f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Commands/core/CacheCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public function tags($tags)
* @aliases cc,cache-clear
* @bootstrap max
* @notify Caches have been cleared.
* @usage drush cc bin
* Choose a bin to clear.
* @usage drush cc bin entity,bootstrap
* Clear the entity and bootstrap cache bins.
*/
Expand All @@ -103,7 +105,10 @@ public function clear($type, array $args, $options = ['cache-clear' => true])

// Do it.
drush_op($types[$type], $args);
$this->logger()->success(dt("'!name' cache was cleared.", ['!name' => $type]));
// Avoid double confirm.
if ($type !== 'bin') {
$this->logger()->success(dt("'!name' cache was cleared.", ['!name' => $type]));
}
}

/**
Expand All @@ -118,6 +123,13 @@ public function interact($input, $output)
$type = $this->io()->choice(dt("Choose a cache to clear"), $choices, 'all');
$input->setArgument('type', $type);
}

if ($input->getArgument('type') == 'bin' && empty($input->getArgument('args'))) {
$bins = Cache::getBins();
$choices = array_combine(array_keys($bins), array_keys($bins));
$chosen = $this->io()->choice(dt("Choose a cache to clear"), $choices, 'default');
$input->setArgument('args', [$chosen]);
}
}

/**
Expand Down Expand Up @@ -305,6 +317,7 @@ public static function clearBins($args = ['default'])
$bins = StringUtils::csvToArray($args);
foreach ($bins as $bin) {
\Drupal::service("cache.$bin")->deleteAll();
Drush::logger()->success("$bin cache bin cleared.");
}
}

Expand Down

0 comments on commit cc3035f

Please sign in to comment.