6 use Drush\Exceptions\UserAbortException;
7 use Symfony\Component\Console\Style\SymfonyStyle;
9 class DrushStyle extends SymfonyStyle
11 public function confirm($question, $default = true)
13 // Automatically accept confirmations if the --yes argument was supplied.
14 if (Drush::affirmative()) {
15 $this->comment($question . ': yes.');
17 } // Automatically cancel confirmations if the --no argument was supplied.
18 elseif (Drush::negative()) {
19 $this->warning($question . ': no.');
23 $return = parent::confirm($question, $default);
28 * @param string $question
29 * @param array $choices
30 * If an associative array is passed, the chosen *key* is returned.
31 * @param null $default
34 public function choice($question, array $choices, $default = null)
36 $choices = array_merge(['cancel' => 'Cancel'], $choices) ;
37 $choices_values = array_values($choices);
38 $return = parent::choice($question, $choices_values, $default);
39 if ($return == 'Cancel') {
40 throw new UserAbortException();
42 return array_search($return, $choices);
46 public function warning($message)
48 $this->block($message, 'WARNING', 'fg=black;bg=yellow', ' ! ', true);
51 public function note($message)
53 $this->block($message, 'NOTE', 'fg=black;bg=yellow', ' ! ');
56 public function caution($message)
58 $this->block($message, 'CAUTION', 'fg=black;bg=yellow', ' ! ', true);