Skip to content

Commit 6b6d9e9

Browse files
committed
Adding option parser to model task.
Adding omitted options to view task.
1 parent 4985572 commit 6b6d9e9

File tree

2 files changed

+19
-63
lines changed

2 files changed

+19
-63
lines changed

cake/console/libs/tasks/model.php

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -873,31 +873,25 @@ public function getName($useDbConfig = null) {
873873
}
874874

875875
/**
876-
* Displays help contents
876+
* get the option parser.
877877
*
878+
* @return void
878879
*/
879-
public function help() {
880-
$this->hr();
881-
$this->out("Usage: cake bake model <arg1>");
882-
$this->hr();
883-
$this->out('Arguments:');
884-
$this->out();
885-
$this->out("<name>");
886-
$this->out("\tName of the model to bake. Can use Plugin.name");
887-
$this->out("\tas a shortcut for plugin baking.");
888-
$this->out();
889-
$this->out('Commands:');
890-
$this->out();
891-
$this->out("model");
892-
$this->out("\tbakes model in interactive mode.");
893-
$this->out();
894-
$this->out("model <name>");
895-
$this->out("\tbakes model file with no associations or validation");
896-
$this->out();
897-
$this->out("model all");
898-
$this->out("\tbakes all model files with associations and validation");
899-
$this->out();
900-
$this->_stop();
880+
public function getOptionParser() {
881+
$parser = parent::getOptionParser();
882+
return $parser->description(
883+
__('Bake models.')
884+
)->addArgument('name', array(
885+
'help' => __('Name of the model to bake. Can use Plugin.name to bake plugin models.')
886+
))->addSubcommand('all', array(
887+
'help' => __('Bake all model files with associations and validation.')
888+
))->addOption('plugin', array(
889+
'short' => 'p',
890+
'help' => __('Plugin to bake the model into.')
891+
))->addOption('connection', array(
892+
'short' => 'c',
893+
'help' => __('The connection the model table is on.')
894+
))->epilog(__('Omitting all arguments and options will enter into an interactive mode.'));
901895
}
902896

903897
/**

cake/console/libs/tasks/view.php

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -420,46 +420,6 @@ public function getTemplate($action) {
420420
return $template;
421421
}
422422

423-
/**
424-
* Displays help contents
425-
*
426-
*/
427-
public function help() {
428-
$this->hr();
429-
$this->out("Usage: cake bake view <arg1> <arg2>...");
430-
$this->hr();
431-
$this->out('Arguments:');
432-
$this->out();
433-
$this->out("<controller>");
434-
$this->out("\tName of the controller views to bake. Can use Plugin.name");
435-
$this->out("\tas a shortcut for plugin baking.");
436-
$this->out();
437-
$this->out("<action>");
438-
$this->out("\tName of the action view to bake");
439-
$this->out();
440-
$this->out('Commands:');
441-
$this->out();
442-
$this->out("view <controller>");
443-
$this->out("\tWill read the given controller for methods");
444-
$this->out("\tand bake corresponding views.");
445-
$this->out("\tUsing the -admin flag will only bake views for actions");
446-
$this->out("\tthat begin with Routing.prefixes.");
447-
$this->out("\tIf var scaffold is found it will bake the CRUD actions");
448-
$this->out("\t(index,view,add,edit)");
449-
$this->out();
450-
$this->out("view <controller> <action>");
451-
$this->out("\tWill bake a template. core templates: (index, add, edit, view)");
452-
$this->out();
453-
$this->out("view <controller> <template> <alias>");
454-
$this->out("\tWill use the template specified");
455-
$this->out("\tbut name the file based on the alias");
456-
$this->out();
457-
$this->out("view all");
458-
$this->out("\tBake all CRUD action views for all controllers.");
459-
$this->out("\tRequires that models and controllers exist.");
460-
$this->_stop();
461-
}
462-
463423
/**
464424
* get the option parser for this task
465425
*
@@ -476,11 +436,13 @@ public function getOptionParser() {
476436
))->addArgument('alias', array(
477437
'help' => __('Will bake the template in <action> but create the filename after <alias>.')
478438
))->addOption('plugin', array(
439+
'short' => 'p',
479440
'help' => __('Plugin to bake the view into.')
480441
))->addOption('admin', array(
481442
'help' => __('Set to only bake views for a prefix in Routing.prefixes'),
482443
'boolean' => true
483444
))->addOption('connection', array(
445+
'short' => 'c',
484446
'help' => __('The connection the connected model is on.')
485447
))->addSubcommand('all', array(
486448
'help' => __('Bake all CRUD action views for all controllers. Requires models and controllers to exist.')

0 commit comments

Comments
 (0)