1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace whm\Smoke\Cli; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatter; |
6
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatterStyle; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
10
|
|
|
use whm\Smoke\Cli\Command\CustomCommand; |
11
|
|
|
use whm\Smoke\Cli\Command\ExplainCommand; |
12
|
|
|
use whm\Smoke\Cli\Command\ScanCommand; |
13
|
|
|
use whm\Smoke\Cli\Command\WarmUpCommand; |
14
|
|
|
|
15
|
|
|
class Application extends \Symfony\Component\Console\Application |
16
|
|
|
{ |
17
|
|
|
public function __construct() |
18
|
|
|
{ |
19
|
|
|
parent::__construct('Smoke', SMOKE_VERSION); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
public function run(InputInterface $input = null, OutputInterface $output = null) |
26
|
|
|
{ |
27
|
|
|
if (null === $output) { |
28
|
|
|
$styles = array(); |
29
|
|
|
$styles['failure'] = new OutputFormatterStyle('red'); |
30
|
|
|
$formatter = new OutputFormatter(false, $styles); |
31
|
|
|
$output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
return parent::run($input, $output); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function doRun(InputInterface $input, OutputInterface $output) |
41
|
|
|
{ |
42
|
|
|
$this->registerCommands(); |
43
|
|
|
|
44
|
|
|
return parent::doRun($input, $output); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Initializes all the commands. |
49
|
|
|
*/ |
50
|
|
|
private function registerCommands() |
51
|
|
|
{ |
52
|
|
|
$this->add(new ScanCommand()); |
53
|
|
|
$this->add(new ExplainCommand()); |
54
|
|
|
$this->add(new WarmUpCommand()); |
55
|
|
|
$this->add(new CustomCommand()); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|