From 212511c5cd145169fcb70c4b3af112afeb791aab Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 1 Nov 2019 12:40:33 +0100 Subject: [PATCH] make screen generate file by default --- src/Console/Command/ScreenFileCommand.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Console/Command/ScreenFileCommand.php b/src/Console/Command/ScreenFileCommand.php index 03670431a5a9..0ad9aa5f9847 100644 --- a/src/Console/Command/ScreenFileCommand.php +++ b/src/Console/Command/ScreenFileCommand.php @@ -28,7 +28,6 @@ use Rector\PhpParser\Printer\BetterStandardPrinter; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symplify\PackageBuilder\Console\Command\CommandNaming; @@ -41,11 +40,6 @@ final class ScreenFileCommand extends AbstractCommand */ private const FILE_ARGUMENT = 'file'; - /** - * @var string - */ - private const OUTPUT_OPTION = 'output'; - /** * @var SymfonyStyle */ @@ -107,7 +101,6 @@ protected function configure(): void $this->setDescription('Load file and print nodes meta data - super helpful to learn to build rules'); $this->addArgument(self::FILE_ARGUMENT, InputArgument::REQUIRED, 'Path to file to be screened'); - $this->addOption(self::OUTPUT_OPTION, 'o', InputOption::VALUE_REQUIRED, 'Path to print decorated file into'); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -123,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->decorateNodes($nodes); // 4. print decorated nodes to output/file - $this->outputDecoratedFileContent($input, $nodes); + $this->outputDecoratedFileContent($nodes, $smartFileInfo); return Shell::CODE_SUCCESS; } @@ -155,16 +148,14 @@ private function decorateNodes(array $nodes): void /** * @param Node[] $nodes */ - private function outputDecoratedFileContent(InputInterface $input, array $nodes): void + private function outputDecoratedFileContent(array $nodes, SmartFileInfo $fileInfo): void { $decoratedFileContent = 'betterStandardPrinter->prettyPrint($nodes); - $outputOption = (string) $input->getOption(self::OUTPUT_OPTION); - if ($outputOption) { - FileSystem::write($outputOption, $decoratedFileContent); - } else { - $this->symfonyStyle->writeln($decoratedFileContent); - } + $outputFileName = 'rector_vision_' . $fileInfo->getFilename(); + FileSystem::write($outputFileName, $decoratedFileContent); + + $this->symfonyStyle->writeln(sprintf('See: %s', $outputFileName)); } /**