Skip to content

Commit 134f483

Browse files
committed
Adding some colours to project task, and fixing verbose output question.
1 parent 4627cc0 commit 134f483

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

cake/console/libs/tasks/project.php

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,15 @@ class ProjectTask extends Shell {
3939
*
4040
* @param string $project Project path
4141
*/
42-
public function execute($project = null) {
43-
if ($project === null) {
44-
if (isset($this->args[0])) {
45-
$project = $this->args[0];
46-
}
42+
public function execute() {
43+
$project = null;
44+
if (isset($this->args[0])) {
45+
$project = $this->args[0];
4746
}
4847

4948
if ($project) {
5049
$this->Dispatch->parseParams(array('-app', $project));
51-
$project = $this->params['working'];
50+
$project = $this->Dispatch->params['working'];
5251
}
5352

5453
if (empty($this->params['skel'])) {
@@ -60,14 +59,14 @@ public function execute($project = null) {
6059

6160
while (!$project) {
6261
$prompt = __("What is the full path for this app including the app directory name?\n Example:");
63-
$default = $this->params['working'] . DS . 'myapp';
62+
$default = $this->Dispatch->params['working'] . DS . 'myapp';
6463
$project = $this->in($prompt . $default, null, $default);
6564
}
6665

6766
if ($project) {
6867
$response = false;
6968
while ($response == false && is_dir($project) === true && file_exists($project . 'config' . 'core.php')) {
70-
$prompt = sprintf(__('A project already exists in this location: %s Overwrite?'), $project);
69+
$prompt = sprintf(__('<warning>A project already exists in this location:</warning> %s Overwrite?'), $project);
7170
$response = $this->in($prompt, array('y','n'), 'n');
7271
if (strtolower($response) === 'n') {
7372
$response = $project = false;
@@ -80,7 +79,7 @@ public function execute($project = null) {
8079
if ($this->createHome($path)) {
8180
$this->out(__('Welcome page created'));
8281
} else {
83-
$this->out(__('The Welcome page was NOT created'));
82+
$this->out(__('The Welcome page was <error>NOT</error> created'));
8483
}
8584

8685
if ($this->securitySalt($path) === true ) {
@@ -109,8 +108,8 @@ public function execute($project = null) {
109108
$this->out(sprintf(__('chmod -R 0777 %s'), $path . DS .'tmp'));
110109
}
111110

112-
$this->params['working'] = $path;
113-
$this->params['app'] = basename($path);
111+
$this->Dispatch->params['working'] = $path;
112+
$this->Dispatch->params['app'] = basename($path);
114113
return true;
115114
}
116115
}
@@ -133,7 +132,7 @@ function bake($path, $skel = null, $skip = array('empty')) {
133132
while (!$skel) {
134133
$skel = $this->in(sprintf(__("What is the path to the directory layout you wish to copy?\nExample: %s"), APP, null, ROOT . DS . 'myapp' . DS));
135134
if ($skel == '') {
136-
$this->out(__('The directory path you supplied was empty. Please try again.'));
135+
$this->err(__('The directory path you supplied was empty. Please try again.'));
137136
} else {
138137
while (is_dir($skel) === false) {
139138
$skel = $this->in(__('Directory path does not exist please choose another:'));
@@ -151,25 +150,21 @@ function bake($path, $skel = null, $skip = array('empty')) {
151150
$looksGood = $this->in(__('Look okay?'), array('y', 'n', 'q'), 'y');
152151

153152
if (strtolower($looksGood) == 'y') {
154-
$verbose = $this->in(__('Do you want verbose output?'), array('y', 'n'), 'n');
155-
156153
$Folder = new Folder($skel);
157154
if (!empty($this->params['empty'])) {
158155
$skip = array();
159156
}
160157
if ($Folder->copy(array('to' => $path, 'skip' => $skip))) {
161158
$this->hr();
162-
$this->out(sprintf(__('Created: %s in %s'), $app, $path));
159+
$this->out(sprintf(__('<success>Created:</success> %s in %s'), $app, $path));
163160
$this->hr();
164161
} else {
165162
$this->err(sprintf(__(" '%s' could not be created properly"), $app));
166163
return false;
167164
}
168165

169-
if (strtolower($verbose) == 'y') {
170-
foreach ($Folder->messages() as $message) {
171-
$this->out($message);
172-
}
166+
foreach ($Folder->messages() as $message) {
167+
$this->out($message, 1, Shell::VERBOSE);
173168
}
174169

175170
return true;

0 commit comments

Comments
 (0)