1 | <?php |
||
12 | class Task |
||
13 | { |
||
14 | private $name; |
||
15 | private $callback; |
||
16 | private $description; |
||
17 | |||
18 | /** |
||
19 | * Task source file location. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $sourceLocation = ''; |
||
24 | |||
25 | /** |
||
26 | * Should we run this task locally? |
||
27 | * |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $local = false; |
||
31 | |||
32 | /** |
||
33 | * List of task names to run before. |
||
34 | * |
||
35 | * @var string[] |
||
36 | */ |
||
37 | private $before = []; |
||
38 | |||
39 | /** |
||
40 | * List of task names to run after. |
||
41 | * |
||
42 | * @var string[] |
||
43 | */ |
||
44 | private $after = []; |
||
45 | |||
46 | /** |
||
47 | * Make task internal and not visible in CLI. |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | private $hidden = false; |
||
52 | |||
53 | /** |
||
54 | * Run task only once on one of hosts. |
||
55 | * |
||
56 | * @var bool |
||
57 | */ |
||
58 | private $once = false; |
||
59 | |||
60 | /** |
||
61 | * Shallow task will not print execution message/finish messages. |
||
62 | * Useful for success messages and info printing. |
||
63 | * |
||
64 | * @var bool |
||
65 | */ |
||
66 | private $shallow = false; |
||
67 | |||
68 | /** |
||
69 | * Limit parallel execution of the task. |
||
70 | * |
||
71 | * @var int|null |
||
72 | */ |
||
73 | private $limit = null; |
||
74 | |||
75 | /** |
||
76 | * @var array|null |
||
77 | */ |
||
78 | private $selector = null; |
||
79 | |||
80 | 14 | public function __construct($name, callable $callback = null) |
|
85 | |||
86 | 2 | public function run(Context $context) |
|
100 | |||
101 | 4 | public function getName() |
|
105 | |||
106 | 1 | public function __toString() |
|
110 | |||
111 | 1 | public function getDescription() |
|
115 | |||
116 | 11 | public function desc(string $description) |
|
121 | |||
122 | public function getSourceLocation(): string |
||
126 | |||
127 | 10 | public function saveSourceLocation() |
|
134 | |||
135 | /** |
||
136 | * Mark this task local. |
||
137 | */ |
||
138 | 1 | public function local() |
|
143 | |||
144 | 1 | public function isLocal() |
|
148 | |||
149 | /** |
||
150 | * Mark this task to run only once on one of hosts. |
||
151 | */ |
||
152 | 1 | public function once() |
|
157 | |||
158 | 1 | public function isOnce() |
|
162 | |||
163 | /** |
||
164 | * Mark task as hidden and not accessible from CLI. |
||
165 | * |
||
166 | * @return $this |
||
167 | */ |
||
168 | 1 | public function hidden() |
|
173 | |||
174 | 1 | public function isHidden() |
|
178 | |||
179 | 2 | public function addBefore(string $task) |
|
184 | |||
185 | 1 | public function addAfter(string $task) |
|
190 | |||
191 | 3 | public function getBefore() |
|
195 | |||
196 | 3 | public function getAfter() |
|
200 | |||
201 | /** |
||
202 | * Sets task as shallow. Shallow task will not print execution message/finish messages. |
||
203 | */ |
||
204 | public function shallow() |
||
209 | |||
210 | public function isShallow() |
||
214 | |||
215 | /** |
||
216 | * @return int|null |
||
217 | */ |
||
218 | public function getLimit(): ?int |
||
222 | |||
223 | /** |
||
224 | * @param int|null $limit |
||
225 | * @return Task |
||
226 | */ |
||
227 | public function limit(?int $limit) |
||
232 | |||
233 | public function select(string $selector) |
||
237 | |||
238 | /** |
||
239 | * @return array|null |
||
240 | */ |
||
241 | 1 | public function getSelector(): ?array |
|
245 | |||
246 | 1 | public function addSelector(?array $newSelector) |
|
256 | } |
||
257 |