@@ -18,18 +18,40 @@ class LiteApp
18
18
/// simple cli support
19
19
///////////////////////////////////////////////////////////////////
20
20
21
+ /**
22
+ * parse from `name=val var2=val2`
23
+ * @var array
24
+ */
21
25
private $ args = [];
26
+
27
+ /**
28
+ * parse from `--name=val --var2=val2 -d`
29
+ * @var array
30
+ */
22
31
private $ opts = [];
32
+
33
+ /** @var string */
23
34
private $ script = '' ;
35
+
36
+ /** @var string */
24
37
private $ command = '' ;
25
38
39
+ /**
40
+ * user add commands
41
+ * @var array
42
+ */
26
43
private $ commands = [];
44
+
45
+ /**
46
+ * description message for the command
47
+ * @var array
48
+ */
27
49
private $ messages = [];
28
50
29
51
/**
30
52
* @param bool $exit
31
53
*/
32
- public function dispatchCli ($ exit = true )
54
+ public function dispatch ($ exit = true )
33
55
{
34
56
$ this ->parseCliArgv ();
35
57
@@ -169,4 +191,105 @@ public function showCommands($err = '')
169
191
exit (0 );
170
192
}
171
193
194
+ ///////////////////////////////////////////////////////////////////////////////////
195
+ /// helper methods
196
+ ///////////////////////////////////////////////////////////////////////////////////
197
+
198
+
199
+ /**
200
+ * @return array
201
+ */
202
+ public function getArgs (): array
203
+ {
204
+ return $ this ->args ;
205
+ }
206
+
207
+ /**
208
+ * @param array $args
209
+ */
210
+ public function setArgs (array $ args )
211
+ {
212
+ $ this ->args = $ args ;
213
+ }
214
+
215
+ /**
216
+ * @return array
217
+ */
218
+ public function getOpts (): array
219
+ {
220
+ return $ this ->opts ;
221
+ }
222
+
223
+ /**
224
+ * @param array $opts
225
+ */
226
+ public function setOpts (array $ opts )
227
+ {
228
+ $ this ->opts = $ opts ;
229
+ }
230
+
231
+ /**
232
+ * @return string
233
+ */
234
+ public function getScript (): string
235
+ {
236
+ return $ this ->script ;
237
+ }
238
+
239
+ /**
240
+ * @param string $script
241
+ */
242
+ public function setScript (string $ script )
243
+ {
244
+ $ this ->script = $ script ;
245
+ }
246
+
247
+ /**
248
+ * @return string
249
+ */
250
+ public function getCommand (): string
251
+ {
252
+ return $ this ->command ;
253
+ }
254
+
255
+ /**
256
+ * @param string $command
257
+ */
258
+ public function setCommand (string $ command )
259
+ {
260
+ $ this ->command = $ command ;
261
+ }
262
+
263
+ /**
264
+ * @return array
265
+ */
266
+ public function getCommands (): array
267
+ {
268
+ return $ this ->commands ;
269
+ }
270
+
271
+ /**
272
+ * @param array $commands
273
+ */
274
+ public function setCommands (array $ commands )
275
+ {
276
+ $ this ->commands = $ commands ;
277
+ }
278
+
279
+ /**
280
+ * @return array
281
+ */
282
+ public function getMessages (): array
283
+ {
284
+ return $ this ->messages ;
285
+ }
286
+
287
+ /**
288
+ * @param array $messages
289
+ */
290
+ public function setMessages (array $ messages )
291
+ {
292
+ $ this ->messages = $ messages ;
293
+ }
294
+
172
295
}
0 commit comments