Skip to content
Permalink
Browse files

Updating formatting.

  • Loading branch information...
mariuswilms committed Sep 26, 2009
1 parent ccbc6f3 commit 7fc14f47b3ad362fd5ae15f4ce9f386a97711b06
Showing with 34 additions and 21 deletions.
  1. +34 −21 cake/console/libs/shell.php
@@ -145,6 +145,7 @@ class Shell extends Object {
*/
function __construct(&$dispatch) {
$vars = array('params', 'args', 'shell', 'shellCommand' => 'command');
foreach ($vars as $key => $var) {
if (is_string($key)) {
$this->{$var} =& $dispatch->{$key};
@@ -205,7 +206,8 @@ function startup() {
*/
function _welcome() {
$this->Dispatch->clear();
$this->out("\nWelcome to CakePHP v" . Configure::version() . " Console");
$this->out();
$this->out('Welcome to CakePHP v' . Configure::version() . ' Console');
$this->hr();
$this->out('App : '. $this->params['app']);
$this->out('Path: '. $this->params['working']);
@@ -224,8 +226,8 @@ function _loadDbConfig() {
$this->DbConfig =& new DATABASE_CONFIG();
return true;
}
$this->err('Database config could not be loaded');
$this->out('Run \'bake\' to create the database configuration');
$this->err('Database config could not be loaded.');
$this->out('Run `bake` to create the database configuration.');
return false;
}
@@ -296,7 +298,7 @@ function loadTasks() {
if (!class_exists($taskClass)) {
foreach ($this->Dispatch->shellPaths as $path) {
$taskPath = $path . 'tasks' . DS . $task.'.php';
$taskPath = $path . 'tasks' . DS . $task . '.php';
if (file_exists($taskPath)) {
require_once $taskPath;
break;
@@ -320,7 +322,7 @@ function loadTasks() {
}
if (!isset($this->{$taskName})) {
$this->err("Task '" . $taskName . "' could not be loaded");
$this->err("Task `{$taskName}` could not be loaded");
$this->_stop();
}
}
@@ -444,7 +446,11 @@ function _checkArgs($expectedNum, $command = null) {
$command = $this->command;
}
if (count($this->args) < $expectedNum) {
$this->error("Wrong number of parameters: ".count($this->args), "Expected: {$expectedNum}\nPlease type 'cake {$this->shell} help' for help on usage of the {$this->name} {$command}");
$message[] = "Got: " . count($this->args);
$message[] = "Expected: {$expectedNum}";
$message[] = "Please type `cake {$this->shell} help` for help";
$message[] = "on usage of the {$this->name} {$command}.";
$this->error('Wrong number of parameters', $message);
}
}
@@ -456,16 +462,21 @@ function _checkArgs($expectedNum, $command = null) {
* @return boolean Success
* @access public
*/
function createFile ($path, $contents) {
function createFile($path, $contents) {
$path = str_replace(DS . DS, DS, $path);
$this->out($this->nl() . sprintf(__("Creating file %s", true), $path));
$this->out();
$this->out(sprintf(__("Creating file %s", true), $path));
if (is_file($path) && $this->interactive === true) {
$key = $this->in(__("File exists, overwrite?", true). " {$path}", array('y', 'n', 'q'), 'n');
$prompt = sprintf(__('File `%s` exists, overwrite?', true), $path);
$key = $this->in($prompt, array('y', 'n', 'q'), 'n');
if (strtolower($key) == 'q') {
$this->out(__("Quitting.", true), 2);
exit;
$this->out(__('Quitting.', true), 2);
$this->_stop();
} elseif (strtolower($key) != 'y') {
$this->out(__("Skip", true) ." {$path}", 2);
$this->out(sprintf(__('Skip `%s`', true), $path), 2);
return false;
}
}
@@ -476,10 +487,10 @@ function createFile ($path, $contents) {
if ($File = new File($path, true)) {
$data = $File->prepare($contents);
$File->write($data);
$this->out(__("Wrote", true) ." {$path}");
$this->out(sprintf(__('Wrote `%s`', true), $path));
return true;
} else {
$this->err(__("Error! Could not write to", true)." {$path}", 2);
$this->err(sprintf(__('Could not write to `%s`.', true), $path), 2);
return false;
}
}
@@ -491,8 +502,8 @@ function createFile ($path, $contents) {
*/
function help() {
if ($this->command != null) {
$this->err("Unknown {$this->name} command '$this->command'.");
$this->err("For usage, try 'cake {$this->shell} help'.", 2);
$this->err("Unknown {$this->name} command `{$this->command}`.");
$this->err("For usage, try `cake {$this->shell} help`.", 2);
} else {
$this->Dispatch->help();
}
@@ -508,11 +519,13 @@ function _checkUnitTest() {
if (App::import('vendor', 'simpletest' . DS . 'simpletest')) {
return true;
}
$unitTest = $this->in('SimpleTest is not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y');
$prompt = 'SimpleTest is not installed. Do you want to bake unit test files anyway?';
$unitTest = $this->in($prompt, array('y','n'), 'y');
$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';
if ($result) {
$this->out("\nYou can download SimpleTest from http://simpletest.org", true);
$this->out();
$this->out('You can download SimpleTest from http://simpletest.org');
}
return $result;
}
@@ -571,7 +584,7 @@ function _modelName($name) {
* @access protected
*/
function _modelKey($name) {
return Inflector::underscore(Inflector::singularize($name)).'_id';
return Inflector::underscore(Inflector::singularize($name)) . '_id';
}
/**
@@ -582,8 +595,7 @@ function _modelKey($name) {
* @access protected
*/
function _modelNameFromKey($key) {
$name = str_replace('_id', '',$key);
return Inflector::camelize($name);
return Inflector::camelize(str_replace('_id', '', $key));
}
/**
@@ -639,6 +651,7 @@ function _pluralHumanName($name) {
function _pluginPath($pluginName) {
$pluginPaths = App::path('plugins');
$pluginDirName = Inflector::underscore($pluginName);
foreach ($pluginPaths as $path) {
if (is_dir($path . $pluginDirName)) {
return $path . $pluginDirName . DS ;

0 comments on commit 7fc14f4

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