From 0b6919ee941fc68cded10b123ec92c32e02a62bd Mon Sep 17 00:00:00 2001 From: euromark Date: Thu, 18 Jul 2013 13:09:00 +0200 Subject: [PATCH] force option for bake tasks (view, model, controller, test, fixture) --- lib/Cake/Console/Command/Task/ControllerTask.php | 3 +++ lib/Cake/Console/Command/Task/FixtureTask.php | 3 +++ lib/Cake/Console/Command/Task/ModelTask.php | 3 +++ lib/Cake/Console/Command/Task/TestTask.php | 3 +++ lib/Cake/Console/Command/Task/ViewTask.php | 3 +++ lib/Cake/Console/Shell.php | 2 +- 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index b50266852..aae11519b 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -477,6 +477,9 @@ class ControllerTask extends BakeTask { ))->addOption('theme', array( 'short' => 't', 'help' => __d('cake_console', 'Theme to use when baking code.') + ))->addOption('force', array( + 'short' => 'f', + 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') ))->addSubcommand('all', array( 'help' => __d('cake_console', 'Bake all controllers with CRUD methods.') ))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index a3e217052..a44b61276 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -90,6 +90,9 @@ class FixtureTask extends BakeTask { ))->addOption('theme', array( 'short' => 't', 'help' => __d('cake_console', 'Theme to use when baking code.') + ))->addOption('force', array( + 'short' => 'f', + 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') ))->addOption('records', array( 'help' => __d('cake_console', 'Used with --count and /all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10.'), 'short' => 'r', diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 0317a05a9..1ae4fcca9 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -998,6 +998,9 @@ class ModelTask extends BakeTask { ))->addOption('connection', array( 'short' => 'c', 'help' => __d('cake_console', 'The connection the model table is on.') + ))->addOption('force', array( + 'short' => 'f', + 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') ))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); } diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 1fe8e390d..5350918ed 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -569,6 +569,9 @@ class TestTask extends BakeTask { ))->addOption('plugin', array( 'short' => 'p', 'help' => __d('cake_console', 'CamelCased name of the plugin to bake tests for.') + ))->addOption('force', array( + 'short' => 'f', + 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') ))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); } diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index 37c6f5228..9307621a3 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -440,6 +440,9 @@ class ViewTask extends BakeTask { ))->addOption('connection', array( 'short' => 'c', 'help' => __d('cake_console', 'The connection the connected model is on.') + ))->addOption('force', array( + 'short' => 'f', + 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') ))->addSubcommand('all', array( 'help' => __d('cake_console', 'Bake all CRUD action views for all controllers. Requires models and controllers to exist.') ))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index ea9cdd156..5f52ecd69 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -693,7 +693,7 @@ class Shell extends Object { $this->out(); - if (is_file($path) && $this->interactive === true) { + if (is_file($path) && empty($this->params['force']) && $this->interactive === true) { $this->out(__d('cake_console', 'File `%s` exists', $path)); $key = $this->in(__d('cake_console', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n');