updating bake and tasks, closes #4326, closes #3993, closes #4032, closes #4337

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6574 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-03-15 05:45:43 +00:00
parent 29fa485140
commit 6a1cdf2138
6 changed files with 42 additions and 10 deletions

View file

@ -41,7 +41,7 @@ class BakeShell extends Shell {
* @var array
* @access public
*/
var $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View', 'Plugin');
var $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View', 'Plugin', 'Test');
/**
* Override loadTasks() to handle paths
*
@ -105,7 +105,7 @@ class BakeShell extends Shell {
exit(0);
break;
default:
$this->out('You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, or C.');
$this->out(__('You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, or C.', true));
}
$this->hr();
$this->main();
@ -198,6 +198,7 @@ class BakeShell extends Shell {
$this->out("\n\tbake help\n\t\tshows this help message.");
$this->out("\n\tbake all <name>\n\t\tbakes complete MVC. optional <name> of a Model");
$this->out("\n\tbake project <path>\n\t\tbakes a new app folder in the path supplied\n\t\tor in current directory if no path is specified");
$this->out("\n\tbake plugin <name>\n\t\tbakes a new plugin folder in the path supplied\n\t\tor in current directory if no path is specified.");
$this->out("\n\tbake db_config\n\t\tbakes a database.php file in config directory.");
$this->out("\n\tbake model\n\t\tbakes a model. run 'bake model help' for more info");
$this->out("\n\tbake view\n\t\tbakes views. run 'bake view help' for more info");

View file

@ -508,8 +508,14 @@ class ControllerTask extends Shell {
} else {
$tables = $db->listSources();
}
if (empty($tables)) {
$this->err(__('Your database does not have any tables.', true));
exit();
}
$this->__tables = $tables;
$this->out('Possible Models based on your current database:');
$this->out('Possible Controllers based on your current database:');
$this->_controllerNames = array();
$count = count($tables);
for ($i = 0; $i < $count; $i++) {

View file

@ -71,6 +71,14 @@ class DbConfigTask extends Shell {
while ($name == '') {
$name = $this->in("Name:", null, 'default');
if (preg_match('/[^a-z0-9_]/i', $name)) {
$name = '';
$this->out('The name may only contain unaccented latin characters, numbers or underscores');
}
else if (preg_match('/^[^a-z_]/i', $name)) {
$name = '';
$this->out('The name must start with an unaccented latin character or an underscore');
}
}
$driver = '';

View file

@ -47,6 +47,14 @@ class ModelTask extends Shell {
* @access public
*/
var $path = MODELS;
/**
* tasks
*
* @var array
* @access public
*/
var $tasks = array('DbConfig');
/**
* Execution method always used for tasks
*
@ -83,7 +91,13 @@ class ModelTask extends Shell {
$associations = array('belongsTo'=> array(), 'hasOne'=> array(), 'hasMany' => array(), 'hasAndBelongsToMany'=> array());
$useDbConfig = 'default';
$connections = array_keys(get_class_vars('DATABASE_CONFIG'));
$configs = get_class_vars('DATABASE_CONFIG');
if (!is_array($configs)) {
return $this->DbConfig->execute();
}
$connections = array_keys($configs);
if (count($connections) > 1) {
$useDbConfig = $this->in(__('Use Database Config', true) .':', $connections, 'default');
}
@ -196,7 +210,7 @@ class ModelTask extends Shell {
}
}
} else {
$this->out('Bake Aborted.');
return false;
}
}
/**
@ -733,6 +747,11 @@ class ModelTask extends Shell {
} else {
$tables = $db->listSources();
}
if (empty($tables)) {
$this->err(__('Your database does not have any tables.', true));
exit();
}
$this->__tables = $tables;
if ($interactive === true) {

View file

@ -92,13 +92,13 @@ class ProjectTask extends Shell {
while (!$response) {
$response = $this->in("What is the full path for this app including the app directory name?\nExample: ".$this->params['root'] . DS . "myapp\n[Q]uit", null, 'Q');
if (strtoupper($response) === 'Q') {
$this->out('Bake Aborted');
$this->out(__('Bake Aborted.', true));
exit();
}
$this->params['working'] = null;
$this->params['app'] = null;
$this->execute($response);
exit();
return true;
}
}
}
@ -107,7 +107,7 @@ class ProjectTask extends Shell {
while (!$project) {
$project = $this->in("What is the full path for this app including the app directory name?\nExample: ".$this->params['root'] . DS . "myapp", null, $this->params['root'] . DS . 'myapp');
$this->execute($project);
exit();
return true;
}
if($this->bake($project)) {
@ -137,7 +137,6 @@ class ProjectTask extends Shell {
$this->out(sprintf(__('chmod -R 0777 %s', true), $path . DS .'tmp'));
}
}
exit();
}
/**
* Looks for a skeleton template of a Cake application,

View file

@ -219,7 +219,6 @@ class ViewTask extends Shell {
exit();
} else {
$this->out('Bake Aborted.');
exit();
}
}
}