2005-07-04 01:07:14 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
/* SVN FILE: $Id$ */
|
2005-05-22 23:24:09 +00:00
|
|
|
/**
|
2006-07-18 11:11:44 +00:00
|
|
|
* Command-line code generation utility to automate programmer chores.
|
2006-07-23 18:59:52 +00:00
|
|
|
*
|
2006-07-18 11:11:44 +00:00
|
|
|
* Bake is CakePHP's code generation script, which can help you kickstart
|
|
|
|
* application development by writing fully functional skeleton controllers,
|
|
|
|
* models, and views. Going further, Bake can also write Unit Tests for you.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
2007-02-02 10:39:45 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
2007-05-14 12:23:25 +00:00
|
|
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
2006-05-26 05:29:17 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
2005-12-23 21:57:26 +00:00
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
2006-01-13 23:53:23 +00:00
|
|
|
* @filesource
|
2007-02-02 10:39:45 +00:00
|
|
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
2006-05-26 05:29:17 +00:00
|
|
|
* @package cake
|
2007-05-14 01:14:41 +00:00
|
|
|
* @subpackage cake.cake.console.libs
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5012
|
2006-05-26 05:29:17 +00:00
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
*/
|
|
|
|
/**
|
2006-07-18 11:11:44 +00:00
|
|
|
* Bake is a command-line code generation utility for automating programmer chores.
|
2006-05-26 05:29:17 +00:00
|
|
|
*
|
|
|
|
* @package cake
|
2007-05-13 20:18:57 +00:00
|
|
|
* @subpackage cake.cake.console.libs
|
2005-08-21 06:49:02 +00:00
|
|
|
*/
|
2007-05-12 21:18:07 +00:00
|
|
|
class BakeShell extends Shell {
|
2006-10-14 18:07:52 +00:00
|
|
|
|
2007-05-14 12:23:25 +00:00
|
|
|
var $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View');
|
2007-05-13 23:11:40 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
function main() {
|
2007-05-14 12:23:25 +00:00
|
|
|
|
2007-05-04 19:32:05 +00:00
|
|
|
if(!is_dir(CONFIGS)) {
|
2007-05-14 12:23:25 +00:00
|
|
|
$this->Project->execute();
|
2007-05-04 19:32:05 +00:00
|
|
|
}
|
2007-05-05 06:00:38 +00:00
|
|
|
|
2007-05-04 19:32:05 +00:00
|
|
|
if(!config('database')) {
|
2007-05-15 04:21:44 +00:00
|
|
|
$this->out("Your database configuration was not found. Take a moment to create one.\n");
|
2007-05-14 12:23:25 +00:00
|
|
|
$this->DbConfig->execute();
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2007-05-14 12:23:25 +00:00
|
|
|
|
2007-05-04 04:37:25 +00:00
|
|
|
$this->out('[M]odel');
|
|
|
|
$this->out('[V]iew');
|
2007-05-13 23:11:40 +00:00
|
|
|
$this->out('[C]ontroller');
|
2007-05-14 01:14:41 +00:00
|
|
|
|
2007-05-14 12:23:25 +00:00
|
|
|
$classToBake = strtoupper($this->in('What would you like to Bake?', array('M', 'V', 'C')));
|
|
|
|
switch($classToBake) {
|
|
|
|
case 'M':
|
|
|
|
$invalidSelection = false;
|
|
|
|
$this->Model->execute();
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
$invalidSelection = false;
|
|
|
|
$this->View->execute();
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
$invalidSelection = false;
|
|
|
|
$this->Controller->execute();
|
|
|
|
break;
|
2006-05-26 05:29:17 +00:00
|
|
|
default:
|
2007-05-14 12:23:25 +00:00
|
|
|
$this->out('You have made an invalid selection. Please choose a type of class to Bake by entering M, V, or C.');
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-14 12:23:25 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
function help() {
|
2007-05-04 04:37:25 +00:00
|
|
|
$this->out('CakePHP Bake:');
|
2006-05-26 05:29:17 +00:00
|
|
|
$this->hr();
|
2007-05-04 04:37:25 +00:00
|
|
|
$this->out('The Bake script generates controllers, views and models for your application.');
|
|
|
|
$this->out('If run with no command line arguments, Bake guides the user through the class');
|
|
|
|
$this->out('creation process. You can customize the generation process by telling Bake');
|
|
|
|
$this->out('where different parts of your application are using command line arguments.');
|
|
|
|
$this->out('');
|
2006-05-26 05:29:17 +00:00
|
|
|
$this->hr('');
|
2007-05-14 12:23:25 +00:00
|
|
|
$this->out('usage: cake bake [command] [params...]');
|
2007-05-04 04:37:25 +00:00
|
|
|
$this->out('');
|
2007-05-14 12:23:25 +00:00
|
|
|
$this->out('params:');
|
|
|
|
$this->out(' -app [path...] Absolute/Relative path to your app folder.');
|
2007-05-04 04:37:25 +00:00
|
|
|
$this->out('commands:');
|
2007-05-14 12:23:25 +00:00
|
|
|
$this->out(' help Shows this help message.');
|
|
|
|
$this->out(' project [path...] Generates a new app folder in the path supplied.');
|
|
|
|
$this->out(' db_config Generates the database configuration file.');
|
2007-05-04 04:37:25 +00:00
|
|
|
$this->out('');
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2006-05-09 02:15:47 +00:00
|
|
|
}
|
2007-05-03 04:35:25 +00:00
|
|
|
?>
|