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 {
|
2007-10-22 05:52:20 +00:00
|
|
|
/**
|
|
|
|
* Contains tasks to load and instantiate
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2007-05-14 12:23:25 +00:00
|
|
|
var $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View');
|
2007-10-22 05:52:20 +00:00
|
|
|
/**
|
|
|
|
* Override main() to handle action
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
*/
|
2006-05-26 05:29:17 +00:00
|
|
|
function main() {
|
2007-06-03 23:56:04 +00:00
|
|
|
|
2007-06-20 06:15:35 +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-06-20 06:15:35 +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-06-04 07:21:17 +00:00
|
|
|
$this->args = null;
|
|
|
|
return $this->DbConfig->execute();
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2007-06-03 23:56:04 +00:00
|
|
|
$this->out('Interactive Bake Shell');
|
|
|
|
$this->hr();
|
2007-09-15 20:23:30 +00:00
|
|
|
$this->out('[D]atabase Configuration');
|
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-10-20 05:55:37 +00:00
|
|
|
$this->out('[P]roject');
|
2007-07-08 23:48:05 +00:00
|
|
|
$this->out('[Q]uit');
|
2007-05-14 01:14:41 +00:00
|
|
|
|
2007-10-20 05:55:37 +00:00
|
|
|
$classToBake = strtoupper($this->in('What would you like to Bake?', array('D', 'M', 'V', 'C', 'P', 'Q')));
|
2007-05-14 12:23:25 +00:00
|
|
|
switch($classToBake) {
|
2007-09-15 20:23:30 +00:00
|
|
|
case 'D':
|
|
|
|
$this->DbConfig->execute();
|
|
|
|
break;
|
2007-05-14 12:23:25 +00:00
|
|
|
case 'M':
|
2007-06-08 07:53:58 +00:00
|
|
|
$this->Model->execute();
|
2007-05-14 12:23:25 +00:00
|
|
|
break;
|
|
|
|
case 'V':
|
2007-06-08 07:53:58 +00:00
|
|
|
$this->View->execute();
|
2007-05-14 12:23:25 +00:00
|
|
|
break;
|
|
|
|
case 'C':
|
2007-06-08 07:53:58 +00:00
|
|
|
$this->Controller->execute();
|
2007-05-14 12:23:25 +00:00
|
|
|
break;
|
2007-10-20 05:55:37 +00:00
|
|
|
case 'P':
|
|
|
|
$this->Project->execute();
|
|
|
|
break;
|
2007-07-08 23:48:05 +00:00
|
|
|
case 'Q':
|
|
|
|
exit(0);
|
|
|
|
break;
|
2006-05-26 05:29:17 +00:00
|
|
|
default:
|
2007-09-15 20:23:30 +00:00
|
|
|
$this->out('You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, or C.');
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2007-06-03 23:56:04 +00:00
|
|
|
$this->hr();
|
|
|
|
$this->main();
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2007-06-08 08:44:34 +00:00
|
|
|
/**
|
|
|
|
* Displays help contents
|
|
|
|
*
|
2007-10-22 05:52:20 +00:00
|
|
|
* @access public
|
2007-06-21 14:38:46 +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.');
|
2007-06-08 08:44:34 +00:00
|
|
|
$this->hr();
|
|
|
|
$this->out("Usage: cake bake <command> <arg1> <arg2>...");
|
|
|
|
$this->hr();
|
|
|
|
$this->out('Params:');
|
|
|
|
$this->out("\t-app <path> Absolute/Relative path to your app folder.\n");
|
|
|
|
$this->out('Commands:');
|
|
|
|
$this->out("\n\tbake help\n\t\tshows this help message.");
|
|
|
|
$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 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");
|
|
|
|
$this->out("\n\tbake controller\n\t\tbakes a controller. run 'bake controller help' for more info");
|
|
|
|
$this->out("");
|
2007-06-21 14:38:46 +00:00
|
|
|
|
2006-05-26 05:29:17 +00:00
|
|
|
}
|
2006-05-09 02:15:47 +00:00
|
|
|
}
|
2007-07-25 04:38:28 +00:00
|
|
|
?>
|