Skip to content
This repository was archived by the owner on May 27, 2019. It is now read-only.

Commit 52d8a45

Browse files
committed
Merge remote-tracking branch 'Deizel/master'
Conflicts: vendors/shells/queue.php
2 parents a361c44 + e6347d5 commit 52d8a45

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

config/sql/queue.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ function after($event = array()) {
4949
),
5050
'created' => array(
5151
'type' => 'datetime',
52-
'null' => false
52+
'null' => true,
53+
'default' => NULL
5354
),
5455
'notbefore' => array(
5556
'type' => 'datetime',

vendors/shells/queue.php

+38-29
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
88
* @link http://github.com/MSeven/cakephp_queue
99
*/
10-
class queueShell extends Shell {
10+
class QueueShell extends Shell {
1111
public $uses = array(
1212
'Queue.QueuedTask'
1313
);
@@ -67,27 +67,28 @@ public function initialize() {
6767
public function help() {
6868
$this->out('CakePHP Queue Plugin:');
6969
$this->hr();
70-
$this->out('Usage:');
71-
$this->out(' cake queue help');
72-
$this->out(' -> Display this Help message');
73-
$this->out(' cake queue add <taskname>');
74-
$this->out(' -> Try to call the cli add() function on a task');
75-
$this->out(' -> tasks may or may not provide this functionality.');
70+
$this->out('Information goes here.');
71+
$this->hr();
72+
$this->out('Usage: cake queue <command> <arg1> <arg2>...');
73+
$this->hr();
74+
$this->out('Commands:');
75+
$this->out(' queue help');
76+
$this->out(' shows this help message.', 2);
77+
$this->out(' queue add <taskname>');
78+
$this->out(' tries to call the cli `add()` function on a task.');
79+
$this->out(' tasks may or may not provide this functionality.', 2);
7680
$this->out(' cake queue runworker [--verbose]');
77-
$this->out(' -> run a queue worker, which will look for a pending task it can execute.');
78-
$this->out(' -> the worker will always try to find jobs matching its installed Tasks');
79-
$this->out(' -> see "Available Tasks" below.');
80-
$this->out(' cake queue stats');
81-
$this->out(' -> Display some general Statistics.');
82-
$this->out(' cake queue clean');
83-
$this->out(' -> Manually call cleanup function to delete task data of completed tasks.');
84-
$this->out('Notes:');
85-
$this->out(' <taskname> may either be the complete classname (eg. queue_example)');
86-
$this->out(' or the shorthand without the leading "queue_" (eg. example)');
87-
$this->out('Available Tasks:');
88-
foreach ($this->taskNames as $loadedTask) {
89-
$this->out(' ->' . $loadedTask);
90-
}
81+
$this->out(' run a queue worker, which will look for a pending task it can execute.');
82+
$this->out(' the worker will always try to find jobs matching its installed tasks.');
83+
$this->out(' see "Available tasks" below.', 2);
84+
$this->out(' queue stats');
85+
$this->out(' display some general statistics.', 2);
86+
$this->out(' queue clean');
87+
$this->out(' manually call cleanup function to delete task data of completed tasks.', 2);
88+
$this->out('Note:');
89+
$this->out(' <taskname> may either be the complete classname (eg. `queue_example`)');
90+
$this->out(' or the shorthand without the leading "queue_" (eg. `example`).', 2);
91+
$this->_listTasks();
9192
}
9293

9394
/**
@@ -97,20 +98,18 @@ public function help() {
9798
*/
9899
public function add() {
99100
if (count($this->args) < 1) {
100-
$this->out('Please call like this:');
101-
$this->out(' cake queue add <taskname>');
101+
$this->out('Usage:');
102+
$this->out(' cake queue add <taskname>', 2);
103+
$this->_listTasks();
102104
} else {
103-
104105
if (in_array($this->args[0], $this->taskNames)) {
105106
$this->{$this->args[0]}->add();
106107
} elseif (in_array('queue_' . $this->args[0], $this->taskNames)) {
107108
$this->{'queue_' . $this->args[0]}->add();
108109
} else {
109-
$this->out('Error: Task not Found: ' . $this->args[0]);
110-
$this->out('Available Tasks:');
111-
foreach ($this->taskNames as $loadedTask) {
112-
$this->out(' * ' . $loadedTask);
113-
}
110+
$this->out('Error:');
111+
$this->out(' Task not found: ' . $this->args[0], 2);
112+
$this->_listTasks();
114113
}
115114
}
116115
}
@@ -241,6 +240,16 @@ private function getTaskConf() {
241240
}
242241
return $this->taskConf;
243242
}
243+
/**
244+
* Output a list of available tasks.
245+
*/
246+
protected function _listTasks() {
247+
$this->out('Available tasks:');
248+
foreach ($this->taskNames as $loadedTask) {
249+
$this->out(' - ' . $loadedTask);
250+
}
251+
}
252+
244253
function out($str='') {
245254
$str = date('Y-m-d H:i:s').' '.$str;
246255
return parent::out($str);

0 commit comments

Comments
 (0)