This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.php
140 lines (114 loc) · 2.98 KB
/
console.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* System Check for the Contao Composer Client
*
* PHP Version 5.3
*
* @copyright bit3 UG 2013
* @author Tristan Lins <tristan.lins@bit3.de>
* @package composer-check
* @license LGPL-3.0+
* @link http://c-c-a.org
*/
if (!class_exists('Runtime')) {
require __DIR__ . DIRECTORY_SEPARATOR . 'bootstrap.php';
}
class console
{
public function run()
{
global $argv;
$shortopts = 'l:h';
$longopts = array('lang:', 'help');
$options = getopt($shortopts, $longopts);
if (isset($options['l'])) {
Runtime::$translator->setLanguage($options['l']);
}
if (isset($options['lang'])) {
Runtime::$translator->setLanguage($options['lang']);
}
if (isset($options['h']) || isset($options['help'])) {
$this->help();
$this->shutdown();
}
/**
* Run checks
*/
$selectedChecks = array();
foreach ($argv as $arg) {
if (isset(ContaoCommunityAlliance_Composer_Check_CheckRunner::$checks[$arg])) {
$selectedChecks[] = $arg;
}
}
if (empty($selectedChecks)) {
$selectedChecks = array_keys(ContaoCommunityAlliance_Composer_Check_CheckRunner::$checks);
}
$this->runChecks($selectedChecks);
$this->shutdown();
}
protected function help()
{
echo <<<EOF
+-----------------------------------------------+
| |
| System Check for the Contao Composer Client |
| |
+-----------------------------------------------+
usage: php composer-check.phar [options] [checks]
Options:
--help -h show this help
--lang -l show messages in specific language (expect this help)
Available checks:
EOF;
foreach (ContaoCommunityAlliance_Composer_Check_CheckRunner::$checks as $key => $class) {
$description = Runtime::$translator->translate('checks', $key, array('%class%' => $class));
printf(PHP_EOL . ' %-16s %s', $key, $description);
}
$this->shutdown();
}
protected function runChecks($selectedChecks)
{
$runner = new ContaoCommunityAlliance_Composer_Check_CheckRunner();
$multipleStatus = $runner->runChecks($selectedChecks);
foreach ($multipleStatus as $status) {
printf(PHP_EOL . '[%s] %s', $status->getCheck(), $status->getState());
printf(PHP_EOL . ' * %s', wordwrap($status->getSummary(), 72, "\n * "));
printf(PHP_EOL . ' > %s', wordwrap($status->getDescription(), 70, "\n > "));
print(PHP_EOL);
}
}
/**
* Run a single check and return the status.
*
* @param string $class
*
* @return ContaoCommunityAlliance_Composer_Check_Status
*/
protected function runCheck($class)
{
}
protected function shutdown()
{
if (count(Runtime::$errors)) {
echo <<<EOF
Some errors occurred:
EOF;
foreach (Runtime::$errors as $error) {
printf(
PHP_EOL . ' [%d] %s',
$error['errno'],
$error['errstr']
);
printf(
PHP_EOL . ' in %s:%d',
$error['errfile'],
$error['errline']
);
}
}
echo PHP_EOL;
exit;
}
}
$console = new console();
$console->run();