|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Povils\PHPMND\Console; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Application as BaseApplication; |
|
6
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class Application |
|
12
|
|
|
* |
|
13
|
|
|
* @package Povils\PHPMND\Console |
|
14
|
|
|
*/ |
|
15
|
|
|
class Application extends BaseApplication |
|
16
|
|
|
{ |
|
17
|
|
|
const VERSION = '1.0.3'; |
|
18
|
|
|
const COMMAND_NAME = 'phpmnd'; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct() |
|
21
|
|
|
{ |
|
22
|
|
|
parent::__construct(self::COMMAND_NAME, self::VERSION); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @inheritdoc |
|
27
|
|
|
* |
|
28
|
|
|
protected function getCommandName(InputInterface $input) |
|
29
|
|
|
{ |
|
30
|
|
|
return self::COMMAND_NAME; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @inheritdoc |
|
35
|
|
|
* |
|
36
|
|
|
protected function getDefaultCommands() |
|
37
|
|
|
{ |
|
38
|
|
|
$defaultCommands = parent::getDefaultCommands(); |
|
39
|
|
|
$defaultCommands[] = new Command; |
|
40
|
|
|
|
|
41
|
|
|
return $defaultCommands; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @inheritdoc |
|
46
|
|
|
* |
|
47
|
|
|
public function getDefinition() |
|
48
|
|
|
{ |
|
49
|
|
|
$inputDefinition = parent::getDefinition(); |
|
50
|
|
|
$inputDefinition->setArguments(); |
|
51
|
|
|
|
|
52
|
|
|
return $inputDefinition; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @inheritdoc |
|
57
|
|
|
*/ |
|
58
|
|
|
public function doRun(InputInterface $input, OutputInterface $output) |
|
59
|
|
|
{ |
|
60
|
|
|
if (false === $input->hasParameterOption('--quiet')) { |
|
61
|
|
|
$output->write( |
|
62
|
|
|
sprintf( |
|
63
|
|
|
'phpmnd %s by Povilas Susinskas' . PHP_EOL, |
|
64
|
|
|
$this->getVersion() |
|
65
|
|
|
) |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if ($input->hasParameterOption('--version') || $input->hasParameterOption('-V')) { |
|
70
|
|
|
exit; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if ('run' === $input->getFirstArgument()) { |
|
74
|
|
|
$input = new ArrayInput(['run','--help']); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
parent::doRun($input, $output); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|