Skip to content

Commit 9234aff

Browse files
✨ Add fix option for command
1 parent 0c3c930 commit 9234aff

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

TwigCS/Command/TwigCSCommand.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ protected function configure()
5050
'Run as if this was started in <working-dir> instead of the current working directory',
5151
getcwd()
5252
),
53+
new InputOption(
54+
'fix',
55+
'f',
56+
InputOption::VALUE_NONE,
57+
'Automatically fix all the fixable violations'
58+
)
5359
])
5460
->addArgument(
5561
'paths',
@@ -69,10 +75,11 @@ protected function configure()
6975
*/
7076
protected function execute(InputInterface $input, OutputInterface $output)
7177
{
72-
$paths = $input->getArgument('paths');
73-
$exclude = $input->getOption('exclude');
74-
$level = $input->getOption('level');
78+
$paths = $input->getArgument('paths');
79+
$exclude = $input->getOption('exclude');
80+
$level = $input->getOption('level');
7581
$currentDir = $input->getOption('working-dir');
82+
$fix = $input->getOption('fix');
7683

7784
$config = new Config([
7885
'paths' => $paths,
@@ -87,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8794
// Execute the linter.
8895
$twig = new StubbedEnvironment();
8996
$linter = new Linter($twig, new Tokenizer($twig));
90-
$report = $linter->run($config->findFiles(), $ruleset);
97+
$report = $linter->run($config->findFiles(), $ruleset, $fix);
9198

9299
// Format the output.
93100
$reporter = new TextFormatter($input, $output);

0 commit comments

Comments
 (0)