/
codestyler
51 lines (38 loc) · 1.14 KB
/
codestyler
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
#!/usr/bin/env php
<?php
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
use DragonCode\CodeStyler\Application;
use DragonCode\CodeStyler\Services\Check;
use DragonCode\CodeStyler\Services\Dependabot;
use DragonCode\CodeStyler\Services\EditorConfig;
use DragonCode\CodeStyler\Services\Fix;
$possible_files = [
__DIR__ . '/../../../autoload.php',
__DIR__ . '/../../autoload.php',
__DIR__ . '/../vendor/autoload.php',
];
$file = null;
foreach ($possible_files as $possible_file) {
if (file_exists($possible_file)) {
$file = $possible_file;
break;
}
}
if (is_null($file)) {
throw new RuntimeException('Unable to locate autoload.php file.');
}
require_once $file;
$script = $argv[1] ?? null;
$processor = match ($script) {
'check' => Check::class,
'fix' => Fix::class,
'dependabot' => Dependabot::class,
'editorconfig' => EditorConfig::class,
default => null
};
if (empty($processor)) {
$script = empty($script) ? '(empty)' : $script;
echo 'ERROR: ⚠️Unknown script parameter: ' . $script;
exit(1);
}
Application::make()->process($processor);