setName('i18n:collect-phrases') ->setDescription('Discovers phrases in the codebase'); $this->setDefinition([ new InputArgument( self::INPUT_KEY_DIRECTORY, InputArgument::OPTIONAL, 'Directory path to parse. Not needed if --magento flag is set' ), new InputOption( self::INPUT_KEY_OUTPUT, self::SHORTCUT_KEY_OUTPUT, InputOption::VALUE_REQUIRED, 'Path (including filename) to an output file. With no file specified, defaults to stdout.' ), new InputOption( self::INPUT_KEY_MAGENTO, self::SHORTCUT_KEY_MAGENTO, InputOption::VALUE_NONE, 'Use the --magento parameter to parse the current Magento codebase.' . ' Omit the parameter if a directory is specified.' ), ]); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $directory = $input->getArgument(self::INPUT_KEY_DIRECTORY); if ($input->getOption(self::INPUT_KEY_MAGENTO)) { $directory = BP; if ($input->getArgument(self::INPUT_KEY_DIRECTORY)) { throw new \InvalidArgumentException('Directory path is not needed when --magento flag is set.'); } } elseif (!$input->getArgument(self::INPUT_KEY_DIRECTORY)) { throw new \InvalidArgumentException('Directory path is needed when --magento flag is not set.'); } $generator = ServiceLocator::getDictionaryGenerator(); $generator->generate( $directory, $input->getOption(self::INPUT_KEY_OUTPUT), $input->getOption(self::INPUT_KEY_MAGENTO) ); $output->writeln('Dictionary successfully processed.'); } }