Skip to content

Commit

Permalink
Adding option parser to model task.
Browse files Browse the repository at this point in the history
Adding omitted options to view task.
  • Loading branch information
markstory committed Oct 14, 2010
1 parent 4985572 commit 6b6d9e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 63 deletions.
40 changes: 17 additions & 23 deletions cake/console/libs/tasks/model.php
Expand Up @@ -873,31 +873,25 @@ public function getName($useDbConfig = null) {
}

/**
* Displays help contents
* get the option parser.
*
* @return void
*/
public function help() {
$this->hr();
$this->out("Usage: cake bake model <arg1>");
$this->hr();
$this->out('Arguments:');
$this->out();
$this->out("<name>");
$this->out("\tName of the model to bake. Can use Plugin.name");
$this->out("\tas a shortcut for plugin baking.");
$this->out();
$this->out('Commands:');
$this->out();
$this->out("model");
$this->out("\tbakes model in interactive mode.");
$this->out();
$this->out("model <name>");
$this->out("\tbakes model file with no associations or validation");
$this->out();
$this->out("model all");
$this->out("\tbakes all model files with associations and validation");
$this->out();
$this->_stop();
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(
__('Bake models.')
)->addArgument('name', array(
'help' => __('Name of the model to bake. Can use Plugin.name to bake plugin models.')
))->addSubcommand('all', array(
'help' => __('Bake all model files with associations and validation.')
))->addOption('plugin', array(
'short' => 'p',
'help' => __('Plugin to bake the model into.')
))->addOption('connection', array(
'short' => 'c',
'help' => __('The connection the model table is on.')
))->epilog(__('Omitting all arguments and options will enter into an interactive mode.'));
}

/**
Expand Down
42 changes: 2 additions & 40 deletions cake/console/libs/tasks/view.php
Expand Up @@ -420,46 +420,6 @@ public function getTemplate($action) {
return $template;
}

/**
* Displays help contents
*
*/
public function help() {
$this->hr();
$this->out("Usage: cake bake view <arg1> <arg2>...");
$this->hr();
$this->out('Arguments:');
$this->out();
$this->out("<controller>");
$this->out("\tName of the controller views to bake. Can use Plugin.name");
$this->out("\tas a shortcut for plugin baking.");
$this->out();
$this->out("<action>");
$this->out("\tName of the action view to bake");
$this->out();
$this->out('Commands:');
$this->out();
$this->out("view <controller>");
$this->out("\tWill read the given controller for methods");
$this->out("\tand bake corresponding views.");
$this->out("\tUsing the -admin flag will only bake views for actions");
$this->out("\tthat begin with Routing.prefixes.");
$this->out("\tIf var scaffold is found it will bake the CRUD actions");
$this->out("\t(index,view,add,edit)");
$this->out();
$this->out("view <controller> <action>");
$this->out("\tWill bake a template. core templates: (index, add, edit, view)");
$this->out();
$this->out("view <controller> <template> <alias>");
$this->out("\tWill use the template specified");
$this->out("\tbut name the file based on the alias");
$this->out();
$this->out("view all");
$this->out("\tBake all CRUD action views for all controllers.");
$this->out("\tRequires that models and controllers exist.");
$this->_stop();
}

/**
* get the option parser for this task
*
Expand All @@ -476,11 +436,13 @@ public function getOptionParser() {
))->addArgument('alias', array(
'help' => __('Will bake the template in <action> but create the filename after <alias>.')
))->addOption('plugin', array(
'short' => 'p',
'help' => __('Plugin to bake the view into.')
))->addOption('admin', array(
'help' => __('Set to only bake views for a prefix in Routing.prefixes'),
'boolean' => true
))->addOption('connection', array(
'short' => 'c',
'help' => __('The connection the connected model is on.')
))->addSubcommand('all', array(
'help' => __('Bake all CRUD action views for all controllers. Requires models and controllers to exist.')
Expand Down

0 comments on commit 6b6d9e9

Please sign in to comment.