Skip to content

Commit 60bbdf0

Browse files
committed
up
1 parent ea17067 commit 60bbdf0

File tree

1 file changed

+124
-1
lines changed

1 file changed

+124
-1
lines changed

Diff for: src/LiteApp.php

+124-1
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,40 @@ class LiteApp
1818
/// simple cli support
1919
///////////////////////////////////////////////////////////////////
2020

21+
/**
22+
* parse from `name=val var2=val2`
23+
* @var array
24+
*/
2125
private $args = [];
26+
27+
/**
28+
* parse from `--name=val --var2=val2 -d`
29+
* @var array
30+
*/
2231
private $opts = [];
32+
33+
/** @var string */
2334
private $script = '';
35+
36+
/** @var string */
2437
private $command = '';
2538

39+
/**
40+
* user add commands
41+
* @var array
42+
*/
2643
private $commands = [];
44+
45+
/**
46+
* description message for the command
47+
* @var array
48+
*/
2749
private $messages = [];
2850

2951
/**
3052
* @param bool $exit
3153
*/
32-
public function dispatchCli($exit = true)
54+
public function dispatch($exit = true)
3355
{
3456
$this->parseCliArgv();
3557

@@ -169,4 +191,105 @@ public function showCommands($err = '')
169191
exit(0);
170192
}
171193

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+
172295
}

0 commit comments

Comments
 (0)