forked from laravel/pint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultCommand.php
More file actions
64 lines (56 loc) · 2.3 KB
/
Copy pathDefaultCommand.php
File metadata and controls
64 lines (56 loc) · 2.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
<?php
namespace App\Commands;
use LaravelZero\Framework\Commands\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class DefaultCommand extends Command
{
/**
* The name of the command.
*
* @var string
*/
protected $name = 'default';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Fix the coding style of the given path';
/**
* The configuration of the command.
*
* @return void
*/
protected function configure()
{
parent::configure();
$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('no-config', '', InputOption::VALUE_NONE, 'Disable loading any configuration file'),
new InputOption('preset', '', InputOption::VALUE_REQUIRED, 'The preset that should be used'),
new InputOption('test', '', InputOption::VALUE_NONE, 'Test for code style errors without fixing them'),
new InputOption('bail', '', InputOption::VALUE_NONE, 'Test for code style errors without fixing them and stop on first error'),
new InputOption('dirty', '', InputOption::VALUE_NONE, 'Only fix files that have uncommitted changes'),
new InputOption('format', '', InputOption::VALUE_REQUIRED, 'The output format that should be used'),
new InputOption('cache-file', '', InputArgument::OPTIONAL, 'The path to the cache file'),
new InputOption('with-exit-status', '', InputOption::VALUE_NONE, 'Exit with status 1 if there were any changes made, 0 otherwise'),
]
);
}
/**
* Execute the console command.
*
* @param \App\Actions\FixCode $fixCode
* @param \App\Actions\ElaborateSummary $elaborateSummary
* @return int
*/
public function handle($fixCode, $elaborateSummary)
{
[$totalFiles, $changes] = $fixCode->execute();
return $elaborateSummary->execute($totalFiles, $changes);
}
}