7
7
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
8
8
* @link http://github.com/MSeven/cakephp_queue
9
9
*/
10
- class queueShell extends Shell {
10
+ class QueueShell extends Shell {
11
11
public $ uses = array (
12
12
'Queue.QueuedTask '
13
13
);
@@ -67,27 +67,28 @@ public function initialize() {
67
67
public function help () {
68
68
$ this ->out ('CakePHP Queue Plugin: ' );
69
69
$ 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 );
76
80
$ 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 ();
91
92
}
92
93
93
94
/**
@@ -97,20 +98,18 @@ public function help() {
97
98
*/
98
99
public function add () {
99
100
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 ();
102
104
} else {
103
-
104
105
if (in_array ($ this ->args [0 ], $ this ->taskNames )) {
105
106
$ this ->{$ this ->args [0 ]}->add ();
106
107
} elseif (in_array ('queue_ ' . $ this ->args [0 ], $ this ->taskNames )) {
107
108
$ this ->{'queue_ ' . $ this ->args [0 ]}->add ();
108
109
} 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 ();
114
113
}
115
114
}
116
115
}
@@ -241,6 +240,16 @@ private function getTaskConf() {
241
240
}
242
241
return $ this ->taskConf ;
243
242
}
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
+
244
253
function out ($ str ='' ) {
245
254
$ str = date ('Y-m-d H:i:s ' ).' ' .$ str ;
246
255
return parent ::out ($ str );
0 commit comments