|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Hogosha\Monitor\Console; |
|
4
|
|
|
|
|
5
|
|
|
use Hogosha\Monitor\Client\GuzzleClient; |
|
6
|
|
|
use Hogosha\Monitor\Configuration\ConfigurationDumper; |
|
7
|
|
|
use Hogosha\Monitor\Configuration\ConfigurationLoader; |
|
8
|
|
|
use Hogosha\Monitor\Console\Handler\InitHandler; |
|
9
|
|
|
use Hogosha\Monitor\Console\Handler\RunHandler; |
|
10
|
|
|
use Hogosha\Monitor\Model\UrlProvider; |
|
11
|
|
|
use Hogosha\Monitor\Monitor; |
|
12
|
|
|
use Hogosha\Monitor\Runner\Runner; |
|
13
|
|
|
use Webmozart\Console\Api\Args\Format\Option; |
|
14
|
|
|
use Webmozart\Console\Config\DefaultApplicationConfig; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @author Guillaume Cavana <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
class MonitorApplicationConfig extends DefaultApplicationConfig |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* {@inheritdoc} |
|
24
|
|
|
*/ |
|
25
|
|
|
protected function configure() |
|
26
|
|
|
{ |
|
27
|
|
|
parent::configure(); |
|
28
|
|
|
|
|
29
|
|
|
$configurationLoader = new ConfigurationLoader( |
|
30
|
|
|
rtrim(getcwd(), DIRECTORY_SEPARATOR), |
|
31
|
|
|
Monitor::CONFIG_FILENAME |
|
32
|
|
|
); |
|
33
|
|
|
$configurationDumper = new ConfigurationDumper(); |
|
34
|
|
|
|
|
35
|
|
|
$runner = new Runner( |
|
36
|
|
|
new UrlProvider($configurationLoader), |
|
37
|
|
|
GuzzleClient::createClient() |
|
38
|
|
|
); |
|
39
|
|
|
|
|
40
|
|
|
$signature = <<<SIGNATURE |
|
41
|
|
|
_____ _ |
|
42
|
|
|
|_ _| | | |
|
43
|
|
|
| | _ __ ___ _ __ __ _ __ _| |_ ___ |
|
44
|
|
|
| | | '__/ _ \| '_ \ / _` |/ _` | __/ _ \ |
|
45
|
|
|
_| |_| | | (_) | | | | (_| | (_| | || __/ |
|
46
|
|
|
|_____|_| \___/|_| |_|\__, |\__,_|\__\___| |
|
47
|
|
|
__/ | |
|
48
|
|
|
|___/ |
|
49
|
|
|
SIGNATURE; |
|
50
|
|
|
|
|
51
|
|
|
$this |
|
52
|
|
|
->setDisplayName($signature."\n".'Irongate Monitor Application') |
|
53
|
|
|
->setName('monitor') |
|
54
|
|
|
->setVersion(Monitor::VERSION) |
|
55
|
|
|
->beginCommand('init') |
|
56
|
|
|
->setDescription('Create a default configuration file if you do not have one') |
|
57
|
|
|
->setHandler(new InitHandler($configurationLoader, $configurationDumper)) |
|
|
|
|
|
|
58
|
|
|
->setHelp('php <info>bin/monitor</info> init') |
|
59
|
|
|
->end() |
|
60
|
|
|
->beginCommand('run') |
|
61
|
|
|
->setDescription('Launch the monitor process') |
|
62
|
|
|
->setHandler(new RunHandler($runner)) |
|
63
|
|
|
->setHelp('php <info>bin/monitor</info> init') |
|
64
|
|
|
->addOption('format', null, Option::OPTIONAL_VALUE, 'The formatter', 'table') |
|
65
|
|
|
->end() |
|
66
|
|
|
; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
This check looks for function calls that miss required arguments.