protected function execute(InputInterface $input, OutputInterface $output) { $request = new Request(Query::parse($input->getArgument('query')), $input->getArgument('index'), $input->getArgument('host')); $output->writeln('<info>Start benchmarking</info>'); $output->writeln(''); $result = (new Client($input->getOption('clear')))->execute($request, (int) $input->getOption('count'), $output); $output->writeln(''); $table = new TableHelper(); $table->setHeaders(['Field', 'Value']); $table->addRows($result->toArray()); $table->render($output); }
/** {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $srcHost = $input->getArgument(self::ATTR_HOST); $srcPort = $input->getOption(self::OPT_PORT); $sort = $input->getOption(self::OPT_SORT); $order = $input->getOption(self::OPT_ORDER); $noZeros = $input->getOption(self::OPT_NO_ZEROS); $columns = ['name' => 'name', 'current-jobs-ready' => 'ready', 'current-jobs-reserved' => 'reserved', 'current-jobs-delayed' => 'delayed', 'current-jobs-buried' => 'buried']; $src = new Pheanstalk($srcHost, $srcPort); $table = new TableHelper(false); $table->setLayout(TableHelper::LAYOUT_BORDERLESS); $table->setHeaders($columns); $tubeNames = $src->listTubes(); ksort($tubeNames); $data = []; foreach ($tubeNames as $tube) { /** @var ArrayResponse $response */ $response = $src->statsTube($tube); $tubeData = $response->getArrayCopy(); $tubeData = array_intersect_key($tubeData, $columns); if ($noZeros) { foreach ($tubeData as $key => $value) { if ('0' === $value) { $tubeData[$key] = ''; } } } $data[] = $tubeData; } $column = array_search($sort, $columns); uasort($data, function (array $a1, array $a2) use($column, $order) { return strnatcmp($a1[$column], $a2[$column]) * $order; }); $table->addRows($data); $table->render($output); }
/** * @param InputInterface $input * @param OutputInterface $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $helper = new TableHelper(); $helper->addRows($this->getModulesData()); $helper->setHeaders(["Code", "Active", "Type", "Version"])->render($output); }