-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultCommand.php
More file actions
113 lines (94 loc) · 3.3 KB
/
Copy pathDefaultCommand.php
File metadata and controls
113 lines (94 loc) · 3.3 KB
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
<?php
declare(strict_types=1);
namespace DragonCode\CodeStyler\Commands;
use App\Actions\ElaborateSummary;
use DragonCode\CodeStyler\Actions\FixCode;
use LaravelZero\Framework\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use function getcwd;
class DefaultCommand extends Command
{
protected $signature = 'default';
protected $description = 'Fix the coding style of the given path';
public function handle(FixCode $fixCode, ElaborateSummary $summary): int
{
[$totalFiles, $changes] = $fixCode->execute();
return $summary->execute($totalFiles, $changes);
}
protected function configure(): void
{
$this->setDefinition(
[
new InputArgument(
'path',
InputArgument::IS_ARRAY,
'The path to fix',
[(string) getcwd()]
),
new InputOption(
'config',
'',
InputOption::VALUE_REQUIRED,
'The configuration that should be used'
),
new InputOption(
'test',
'',
InputOption::VALUE_NONE,
'Test for code style errors without fixing them'
),
new InputOption(
'risky',
'',
InputOption::VALUE_NONE,
'Allows the application of risky rules'
),
new InputOption(
'diff',
'',
InputOption::VALUE_REQUIRED,
'Only fix files that have changed since branching off from the given branch',
null,
['main', 'master', 'origin/main', 'origin/master']
),
new InputOption(
'dirty',
'',
InputOption::VALUE_NONE,
'Only fix files that have uncommitted changes'
),
new InputOption(
'bail',
'',
InputOption::VALUE_NONE,
'Test for code style errors without fixing them and stop on first error'
),
new InputOption(
'repair',
'',
InputOption::VALUE_NONE,
'Fix code style errors but exit with status 1 if there were any changes made'
),
new InputOption(
'output-to-file',
'',
InputOption::VALUE_REQUIRED,
'Output the test results to a file at this path'
),
new InputOption(
'format',
'',
InputOption::VALUE_REQUIRED,
'The output format that should be used'
),
new InputOption(
'parallel',
'p',
InputOption::VALUE_NONE,
'Runs the linter in parallel (Experimental)'
),
]
);
}
}