/** * @param Symfony\Component\Console\Input\InputInterface * @param Symfony\Component\Console\Output\OutputInterface * * @return void */ public function execute(InputInterface $input, OutputInterface $output) { $builder = new Builder(new Logger('console'), __DIR__); foreach ($builder->getAdapters() as $adapter) { $output->writeln(sprintf('<comment>% 6s</comment> | <info>%s</info>', $adapter->getPriority(), $adapter->getName())); } }
/** * @param Symfony\Component\Console\Input\InputInterface * @param Symfony\Component\Console\Output\OutputInterface * * @return void */ public function execute(InputInterface $input, OutputInterface $output) { $source = $input->getArgument('source'); if (!is_dir($source)) { throw new RuntimeException('Yuhao does not support remote sources yet.'); } $logger = new Logger('console'); $logger->pushHandler(new ConsoleHandler($output)); $adapters = []; foreach ($input->getOption('builder') as $path) { if (class_exists($className = 'Yuhao\\Adapter\\' . $path . 'Adapter')) { $adapters[] = new $className(); continue; } if (!file_exists($path)) { throw new InvalidArgumentException(sprintf('Custom builder "%s" not found ', $path)); } $className = basename($path, '.php'); require_once $path; if (!class_exists($className)) { throw new InvalidArgumentException(sprintf('Custom builder class "%s" not found in "%s"', $className, $path)); } $adapters[] = new $className(); } $builder = new Builder($logger, $source, $adapters); $types = ['build' => '', 'run' => '', 'config' => []]; foreach ($types as $type => $default) { $scripts[$type] = $builder->exec($type, $default); } $output->writeln(json_encode($scripts, JSON_PRETTY_PRINT)); }