/** * @param InputInterface $input * @param OutputInterface $output * * @return int|null|void */ public function execute(InputInterface $input, OutputInterface $output) { $lists = $this->rfcService->getLists([RfcService::IN_VOTING]); $rfcs = array_pop($lists); $table = new Table($output); $voteStyle = new TableStyle(); $voteStyle->setCellRowFormat('<comment>%s</comment>'); $rfcStyle = new TableStyle(); $rfcStyle->setCellRowFormat('<info>%s</info>'); foreach ($rfcs as $i => $rfcDetails) { $rfcCode = $rfcDetails[1]; // Build RFC $rfc = $this->rfcService->getRfc($rfcCode); $table->addRow([$rfcDetails[0]], $rfcStyle); $table->addRow(new TableSeparator()); foreach ($rfc->getVotes() as $title => $vote) { $table->addRow([$title], $voteStyle); array_shift($vote['counts']); foreach ($vote['counts'] as $key => $total) { $table->addRow([$key, $total]); } } if ($rfcDetails !== end($rfcs)) { $table->addRow(new TableSeparator()); } } $table->render(); }
/** * Execute Command * * @param InputInterface $input * @param OutputInterface $output */ public function execute(InputInterface $input, OutputInterface $output) { $sections = ['voting' => RfcService::IN_VOTING, 'discussion' => RfcService::DISCUSSION, 'draft' => RfcService::DRAFT, 'accepted' => RfcService::ACCEPTED, 'declined' => RfcService::DECLINED, 'withdrawn' => RfcService::WITHDRAWN, 'inactive' => RfcService::INACTIVE]; $sections = array_intersect_key($sections, array_filter($input->getOptions())); if (count($sections) === 0 && !$input->getOption('all')) { $sections[] = RfcService::IN_VOTING; } $table = new Table($output); $titleStyle = new TableStyle(); $titleStyle->setCellRowFormat('<comment>%s</comment>'); $lists = $this->rfcService->getLists($sections); $table->setHeaders(['RFC', 'RFC Code']); foreach ($lists as $heading => $list) { $table->addRow([$heading], $titleStyle); $table->addRow(new TableSeparator()); foreach ($list as $listing) { $table->addRow($listing); } if ($list !== end($lists)) { $table->addRow(new TableSeparator()); } } $table->render(); }