Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $locales = $input->getOption('locale');
     $path = $input->getArgument('path');
     $output->writeln('');
     $output->writeln(sprintf('Check at <info>%s</info> directory', $path));
     $parser = new ParserManager();
     // TODO register parsers depends on config in command
     $parser->registerParser(new TextParser());
     $parser->registerParser(new HtmlParser());
     $parser->registerParser(new PhpParser());
     $parser->registerParser(new TwigParser());
     $parser->parse($path);
     $result = $this->speller->check($parser->getWords(), $locales);
     $output->writeln(sprintf('Checked %s words', $result->getCountOfWords()));
     if (count($result->getMisspelledWords()) > 0) {
         $output->writeln(sprintf('Spell checking failed with %s errors', count($result->getMisspelledWords())));
         $output->writeln('');
         foreach ($result->getMisspelledWords() as $word) {
             $output->writeln(sprintf('Line #%s, file %s', $word->getLineNumber(), $word->getFile()));
             $output->writeln(str_replace($word->getWord(), '<error>' . $word->getWord() . '</error>', $word->getLine()));
             $output->writeln('');
         }
         return 1;
     }
     $output->writeln('<info>No error found</info>');
     return 0;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $info = $this->speller->getInfo();
     $output->writeln('Available Enchant backends:');
     $table = new Table($output);
     $table->setHeaders(array('Provider', 'Description'));
     foreach ($info['providers'] as $backend) {
         $table->addRow(array($backend['name'], $backend['desc']));
     }
     $table->render();
     $output->writeln('Available Enchant dictionaries:');
     $table = new Table($output);
     $table->setHeaders(array('Lang', 'Provider', 'Description'));
     foreach ($info['dictionaries'] as $dictionary) {
         $table->addRow(array($dictionary['lang_tag'], $dictionary['provider_name'], $dictionary['provider_desc']));
     }
     $table->render();
 }