Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     $patterns = $input->getOption('url-pattern');
     if (!$patterns) {
         $output->writeln('<error>Need at least one url-pattern.</error>');
         return 1;
     }
     if ($input->getOption('allow-empty')) {
         $patterns[] = '^$';
     }
     try {
         $json = $this->readJsonFromFile($input->getArgument('file'));
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
         return 1;
     }
     $errors = $this->searchUrlPatterns($json, $patterns, $output);
     if ($errors) {
         $rows = array();
         foreach ($errors as $package => $url) {
             $rows[] = array($package, $url);
         }
         $this->printTable($rows);
         return 1;
     }
     $output->writeln('<info>All urls valid.</info>');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     try {
         $json = $this->readJsonFromFile($input->getArgument('file'));
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
         return 1;
     }
     $newContent = $this->removeDistUrls($json, $input->getOption('except'));
     $this->updateJsonContentInFile($input->getArgument('file'), $newContent);
 }