Skip to content
Permalink
Browse files

Adding question style to ConsoleOutput.

Made Shell::in() draw as magenta text.
  • Loading branch information...
markstory committed Oct 24, 2010
1 parent 6f29519 commit 138482741f9a395cbd687e576e597cf4c51cce17
Showing with 10 additions and 6 deletions.
  1. +3 −1 cake/console/libs/console_output.php
  2. +7 −5 cake/console/shells/shell.php
@@ -28,6 +28,7 @@
* - `warning` Warning messages.
* - `info` Informational messages.
* - `comment` Additional text.
* - `question` Magenta text used for user prompts
*
* By defining styles with addStyle() you can create custom console styles.
*
@@ -133,7 +134,8 @@ class ConsoleOutput {
'warning' => array('text' => 'yellow'),
'info' => array('text' => 'cyan'),
'success' => array('text' => 'green'),
'comment' => array('text' => 'blue')
'comment' => array('text' => 'blue'),
'question' => array('text' => "magenta"),
);
/**
@@ -442,9 +442,9 @@ protected function _getInput($prompt, $options, $default) {
}
if ($default === null) {
$this->stdout->write($prompt . " $printOptions \n" . '> ', 0);
$this->stdout->write('<question>' . $prompt . '</question>' . " $printOptions \n" . '> ', 0);
} else {
$this->stdout->write($prompt . " $printOptions \n" . "[$default] > ", 0);
$this->stdout->write('<question>' . $prompt . '</question>' . " $printOptions \n" . "[$default] > ", 0);
}
$result = $this->stdin->read();
@@ -584,11 +584,10 @@ public function createFile($path, $contents) {
$path = str_replace(DS . DS, DS, $path);
$this->out();
$this->out(sprintf(__('Creating file %s'), $path));
if (is_file($path) && $this->interactive === true) {
$prompt = sprintf(__('<warning>File `%s` exists</warning>, overwrite?'), $path);
$key = $this->in($prompt, array('y', 'n', 'q'), 'n');
$this->out(sprintf(__('<warning>File `%s` exists</warning>'), $path));
$key = $this->in(__('Do you want to overwrite?'), array('y', 'n', 'q'), 'n');
if (strtolower($key) == 'q') {
$this->out(__('<error>Quitting</error>.'), 2);
@@ -597,7 +596,10 @@ public function createFile($path, $contents) {
$this->out(sprintf(__('Skip `%s`'), $path), 2);
return false;
}
} else {
$this->out(sprintf(__('Creating file %s'), $path));
}
if (!class_exists('File')) {
require LIBS . 'file.php';
}

0 comments on commit 1384827

Please sign in to comment.
You can’t perform that action at this time.