rflint%ryanflint.com ad95e006a4 Bug 378977 - Migrate to and ship with Cake 1.2 (part 1) - r=reed a=me
git-svn-id: svn://10.0.0.236/trunk@226993 18797224-902f-48f8-a5cc-f745e15eee43
2007-05-25 05:54:28 +00:00

95 lines
3.1 KiB
PHP
Executable File

<?php
/* SVN FILE: $Id: bake.php,v 1.1 2007-05-25 05:54:16 rflint%ryanflint.com Exp $ */
/**
* Command-line code generation utility to automate programmer chores.
*
* 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.
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2005-2007, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.console.libs
* @since CakePHP(tm) v 1.2.0.5012
* @version $Revision: 1.1 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2007-05-25 05:54:16 $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Bake is a command-line code generation utility for automating programmer chores.
*
* @package cake
* @subpackage cake.cake.console.libs
*/
class BakeShell extends Shell {
var $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View');
function main() {
if(!is_dir(CONFIGS)) {
$this->Project->execute();
}
if(!config('database')) {
$this->out("Your database configuration was not found. Take a moment to create one.\n");
$this->DbConfig->execute();
}
$this->out('[M]odel');
$this->out('[V]iew');
$this->out('[C]ontroller');
$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;
default:
$this->out('You have made an invalid selection. Please choose a type of class to Bake by entering M, V, or C.');
}
}
function help() {
$this->out('CakePHP Bake:');
$this->hr();
$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('');
$this->hr('');
$this->out('usage: cake bake [command] [params...]');
$this->out('');
$this->out('params:');
$this->out(' -app [path...] Absolute/Relative path to your app folder.');
$this->out('commands:');
$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.');
$this->out('');
}
}
?>