Exemple #1
0
 /**
  * {@inheritDoc}
  */
 protected function doExecute()
 {
     $table = new Table($this->output);
     $table->setHeaders(['Name', 'Description']);
     $style = new TableStyle();
     $style->setCellHeaderFormat('<fg=red>%s</fg=red>');
     $style->setCellRowFormat('<fg=blue>%s</fg=blue>');
     $style->setBorderFormat('<fg=yellow>%s</fg=yellow>');
     $table->setStyle($style);
     /** @type AbstractTask[] $services */
     $services = $this->container->get('bldr.registry.task')->findAll();
     foreach ($services as $service) {
         if ($service instanceof AbstractTask) {
             $service->configure();
         }
         $table->addRow([$service->getName(), $service->getDescription() !== '' ? $service->getDescription() : 'No Description']);
     }
     $table->render($this->output);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var FormatterHelper $formatter */
     $formatter = $this->getHelper('formatter');
     $message = $formatter->formatSection('Section', 'Hello!', 'comment');
     $output->writeln($message);
     $blockMessage = $formatter->formatBlock(['Good luck!'], 'bg=black;fg=white', true);
     $output->writeln($blockMessage);
     /** @var ProcessHelper $processHelper */
     $processHelper = $this->getHelper('process');
     $process = ProcessBuilder::create(['figlet', 'Started!'])->getProcess();
     $processHelper->run($output, $process, 'Something went wrong');
     $finder = new Finder();
     $files = $finder->in(CACHE_PATH)->name('makes*json')->files();
     $progressHelper = new ProgressBar($output);
     $progressHelper->setEmptyBarCharacter('.');
     $progressHelper->setBarCharacter('<comment>+</comment>');
     if ($input->getOption('progress')) {
         $progressHelper->start($files->count());
     }
     $table = new Table($output);
     $table->setStyle('default');
     $style = new TableStyle();
     $style->setBorderFormat('<comment>%s</comment>');
     $table->setStyle($style);
     foreach ($files as $file) {
         /** @var SplFileInfo $file */
         $makes = json_decode($file->getContents(), true);
         $table->setHeaders(['Make Name', 'Models Count']);
         foreach ($makes['makes'] as $make) {
             $table->addRow([$make['name'], count($make['models'])]);
         }
         //            $table->render($output);
         if ($input->getOption('progress')) {
             $progressHelper->advance();
         }
     }
     if ($input->getOption('progress')) {
         $progressHelper->finish();
         $output->writeln('');
     }
 }
Exemple #3
0
 /**
  * {@inheritDoc}
  */
 protected function doExecute()
 {
     /** @type AbstractTask $service */
     $service = $this->container->get('bldr.registry.task')->findTaskByType($this->input->getArgument('task'));
     $this->output->writeln('');
     $this->output->writeln('<fg=green>Task Name</fg=green>: ' . $service->getName());
     if ($service->getDescription() !== null) {
         $this->output->writeln('<fg=green>Task Description</fg=green>: ' . $service->getDescription());
     }
     if ($service instanceof AbstractTask) {
         $this->output->writeln(['', '<fg=green>Options:</fg=green>']);
         $tableHelper = new Table($this->output);
         $style = new TableStyle();
         $style->setCellHeaderFormat('<fg=red>%s</fg=red>');
         $style->setCellRowFormat('<fg=blue>%s</fg=blue>');
         $style->setBorderFormat('<fg=yellow>%s</fg=yellow>');
         $tableHelper->setStyle($style);
         $tableHelper->setHeaders(['Option', 'Description', 'Required', "Default"]);
         foreach ($service->getParameterDefinition() as $option) {
             $tableHelper->addRow([$option['name'], $option['description'] !== '' ? $option['description'] : 'No Description', $option['required'] ? 'Yes' : 'No', json_encode($option['default'])]);
         }
         $tableHelper->render();
     }
 }