/**
  * Executes this command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input  Input options.
  * @param \Symfony\Component\Console\Output\OutputInterface $output Output stream.
  * @return void
  *
  * @throws \Helmich\TypoScriptLint\Exception\BadOutputFileException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filenames = $input->getArgument('filename');
     $outputTarget = $input->getOption('output');
     $exitWithExitCode = $input->getOption('exit-code');
     if (FALSE == $outputTarget) {
         throw new BadOutputFileException('Bad output file.');
     }
     $reportOutput = $input->getOption('output') === '-' ? $output : new StreamOutput(fopen($input->getOption('output'), 'w'));
     $configuration = $this->linterConfigurationLocator->loadConfiguration($input->getOption('config'));
     $printer = $this->printerLocator->createPrinter($input->getOption('format'), $reportOutput);
     $report = new Report();
     foreach ($this->finder->getFilenames($filenames) as $filename) {
         $output->writeln("Linting input file <comment>{$filename}</comment>.");
         $this->linter->lintFile($filename, $report, $configuration, $output);
     }
     $printer->writeReport($report);
     if ($exitWithExitCode) {
         $exitCode = $report->countWarnings() > 0 ? 2 : 0;
         $this->eventDispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) use($exitCode) {
             $event->setExitCode($exitCode);
         });
     }
 }
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testInvalidArgumentExceptionIsThrownOnUnknownFormat()
 {
     $this->locator->createPrinter('pdf', new NullOutput());
 }