Skip to content

Commit

Permalink
Merge pull request #39 from mbrodala/patch-2
Browse files Browse the repository at this point in the history
Add "--fail-on-match" CLI option
  • Loading branch information
Tuurlijk committed Sep 17, 2020
2 parents 2d9f8c6 + a91be10 commit 8ff8635
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/TYPO3Scan/Command/ScanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected function configure()
new InputOption('format', 'f', InputOption::VALUE_OPTIONAL, 'Output format', 'plain'),
new InputOption('reportFile', 'r', InputOption::VALUE_OPTIONAL, 'Report file', null),
new InputOption('templatePath', null, InputOption::VALUE_OPTIONAL, 'Path to template folder'),
new InputOption('failOnMatch', null, InputOption::VALUE_NONE, 'Fail if there are matches, useful for CI checks', false),
])
->setHelp(<<<EOT
The <info>scan</info> command scans a path for deprectated code</info>.
Expand All @@ -84,6 +85,9 @@ protected function configure()
Scan a folder for v7 changes, only show the breaking changes and output in markdown:
<info>php typo3scan.phar scan --target 7 --only breaking --format markdown ~/tmp/source</info>
Scan a folder for changes, fail if there are matches (useful for CI checks):
<info>php typo3scan.phar scan --target 10 --only breaking --fail-on-match ~/tmp/source</info>
EOT
);
}
Expand All @@ -94,7 +98,7 @@ protected function configure()
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void|int
* @return int
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
Expand Down Expand Up @@ -183,6 +187,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
$output->write($template->render($context));
}

if ($total > 0 && $input->getOption('failOnMatch')) {
return 1;
}

return 0;
}

/**
Expand Down

0 comments on commit 8ff8635

Please sign in to comment.