public function write(Table $table, UuidInterface $uuid) { $table->addRows(array(array('encode:', 'STR:', (string) $uuid), array('', 'INT:', (string) $uuid->getInteger()))); if ($uuid->getVariant() == Uuid::RFC_4122) { $table->addRows(array(array('decode:', 'variant:', $this->getFormattedVariant($uuid)), array('', 'version:', $this->getFormattedVersion($uuid)))); $table->addRows($this->getContent($uuid)); } else { $table->addRows(array(array('decode:', 'variant:', 'Not an RFC 4122 UUID'))); } }
private function showDown(PokerGame $pokerGame) { $pokerGame->scoreHand(); $table = new Table($this->output); foreach ($pokerGame->pokerPlayers as $player) { $finalHand = $player->showBestHand(); $table->addRows([$finalHand]); } $finalHand = $pokerGame->hero->showBestHand(); $table->addRows([$finalHand]); $table->render($this->output); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->validateInput($input); $environment = $this->getSelectedEnvironment(); $limit = (int) $input->getOption('limit'); $activities = $environment->getActivities($limit, $input->getOption('type')); if (!$activities) { $this->stdErr->writeln('No activities found'); return 1; } $headers = array("ID", "Created", "Description", "% Complete", "Result"); $rows = array(); foreach ($activities as $activity) { $description = $activity->getDescription(); $description = wordwrap($description, 40); $rows[] = array($activity['id'], date('Y-m-d H:i:s', strtotime($activity['created_at'])), $description, $activity->getCompletionPercent(), $activity->state); } if ($output instanceof StreamOutput && ($input->getOption('pipe') || !$this->isTerminal($output))) { $stream = $output->getStream(); array_unshift($rows, $headers); foreach ($rows as $row) { fputcsv($stream, $row, "\t"); } return 0; } $this->stdErr->writeln("Recent activities for the environment <info>" . $environment['id'] . "</info>"); $table = new Table($output); $table->setHeaders($headers); $table->addRows($rows); $table->render(); return 0; }
protected function execute(InputInterface $input, OutputInterface $output) { $projectName = $input->getOption('project_name'); $serviceName = $input->getOption('service_name'); $em = $this->get('entity_manager'); /* * Get Entities */ $projectRepository = $em->getRepository('Mindgruve\\Gruver\\Entity\\Project'); $serviceRepository = $em->getRepository('Mindgruve\\Gruver\\Entity\\Service'); $releaseRepository = $em->getRepository('Mindgruve\\Gruver\\Entity\\Release'); $project = $projectRepository->loadProjectByName($projectName); if (!$project) { $output->writeln('<error>Project ' . $projectName . ' does not exist </error>'); return; } /** * Check if Configuration needs to be reloaded */ $this->checkConfigHash($project, $input, $output); $service = $serviceRepository->loadServiceByName($project, $serviceName); /* * Check if Service Exists */ if (!$service) { $output->writeln('<error>Service ' . $serviceName . ' does not exist </error>'); return; } $output->writeln(''); /* * Current Release */ $currentRelease = $service->getCurrentRelease(); $pendingRelease = $service->getPendingRelease(); $rollbackRelease = $service->getRollbackRelease(); $releases = $releaseRepository->findAll($project, $service); $rows = array(); foreach ($releases as $release) { $status = ''; $tag = $release->getTag(); if ($pendingRelease && $release->getId() == $pendingRelease->getId()) { $status = '<comment>pending</comment>'; } if ($currentRelease && $release->getId() == $currentRelease->getId()) { $status = '<info>current</info>'; } if ($rollbackRelease && $release->getId() == $rollbackRelease->getId()) { $status = 'rollback'; } $date = 'n/a'; if ($release->getCreatedAt()) { $date = DateTimeHelper::humanTimeDiff($release->getCreatedAt()->getTimestamp()); } $rows[] = array($tag . ' ' . $status, $date, $release->getContainerID(), $release->getContainerIp(), $release->getContainerPort(), $release->getId(), $release->getUuid()); } $table = new Table($output); $table->setHeaders(array('Tag', 'Run Date', 'Container', 'IP', 'Port', 'ID', 'UUID')); $table->addRows($rows); $table->render(); }
public function execute(InputInterface $input, OutputInterface $output) { $app = $this->getSilexApplication(); $entity = str_replace('.', '\\', $input->getArgument('entity')); /** @var EntityManagerInterface $em */ $em = $app['orm.em']; $qb = $em->createQueryBuilder()->from($entity, 'main'); if ($input->getOption('columns')) { $qb->select($input->getOption('columns')); } else { $qb->select('main'); } if ($input->getOption('limit')) { $qb->setMaxResults($input->getOption('limit')); if ($input->getOption('start') !== null) { $qb->setFirstResult($input->getOption('start')); } } if ($input->getOption('filter')) { $qb->where($input->getOption('filter')); } $query = $qb->getQuery(); $results = $query->getResult('simple'); if (empty($results)) { $output->writeln('<info>No Results</info>'); return; } $table = new Table($output); $table->setHeaders(array_keys($results[0])); $table->addRows($results); $table->render(); }
/** * @param OutputInterface $output * @param array $actions * @param bool $empty */ protected function render(OutputInterface $output, array $actions, $empty = false) { $fields = ['action' => 'name', 'workers' => 'current-watching', 'reserved' => 'current-jobs-reserved', 'ready' => 'current-jobs-ready', 'urgent' => 'current-jobs-urgent', 'delayed' => 'current-jobs-delayed', 'buried' => 'current-jobs-buried']; $table = new Table($output); $table->setHeaders(array_keys($fields)); $rows = []; foreach ($actions as $action) { if (!($stats = $this->manager->getActionStats($action))) { if (!$empty) { continue; } $stats = array_combine(array_values($fields), array_fill(0, sizeof($fields), '-')); $stats['name'] = $action; } $rows[$action] = array_map(function ($field) use($stats) { return $stats[$field]; }, $fields); } ksort($rows); $table->addRows($rows); if ($this->lineCount) { // move back to the beginning $output->write("[0G"); $output->write(sprintf("[%dA", $this->lineCount)); // overwrite the complete table before rendering the new one $width = $this->getApplication()->getTerminalDimensions()[0]; $lines = array_fill(0, $this->lineCount, str_pad('', $width, ' ')); $output->writeln($lines); $output->write(sprintf("[%dA", $this->lineCount)); } // render the new table $table->render(); // top table border + header + header border + bottom table border = 4 $this->lineCount = 4 + sizeof($rows); }
protected function renderConfig(OutputInterface $output, array $config) { $table = new Table($output); $rows = array_map(function ($a, $b) { return [$a, $b]; }, array_keys($config), $config); $table->addRows($rows); $table->render(); }
protected function execute(InputInterface $input, OutputInterface $output) { list($initTime1, $finishTime1) = $this->testThread(); list($initTime2, $finishTime2) = $this->testPool(); $table = new Table($output); $table->setHeaders(['Test', 'Start Time', 'Finish Time']); $table->addRows([['Thread', $initTime1, $finishTime1], ['Pool', $initTime2, $finishTime2]]); $table->render(); }
/** * @param \ReflectionClass[] $classes * @param OutputInterface $output */ private function renderClassesToDeFinalize(array $classes, OutputInterface $output) { $tableHelper = new Table($output); if ($toDeFinalize = $this->getClassesToDeFinalize($classes)) { $output->writeln('<error>Following classes are final and need to be made extensible again:</error>'); $tableHelper->addRows(array_map(function (\ReflectionClass $class) { return [$class->getName()]; }, $toDeFinalize)); $tableHelper->render(); } }
protected function execute(InputInterface $input, OutputInterface $output) { $stringLength = $input->getOption('string-length'); $setIterationCount = $input->getArgument('set-count'); $getIterationCount = $input->getArgument('get-count'); $redisTest = new Redis($input->getOption('host'), $stringLength); $stats = $redisTest->test($setIterationCount, $getIterationCount); $table = new Table($output); $table->setHeaders(['Count', 'Length (bytes)', 'Type', 'Time (seconds)']); $table->addRows([[$setIterationCount, $stringLength, 'set', $stats['set']], [$getIterationCount, $stringLength, 'get', $stats['get']]]); $table->render(); }
protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->container->getDoctrine()->getManager($input->getOption('em')); $users = $em->getRepository('CmsAuthentication:Group')->findBy(array(), array('name' => 'ASC')); $table = new Table($output); $table->setHeaders(array('ID', 'Name', 'Super')); $table->addRows(array_map(function ($group) { /* @var $group Group */ return array($group->getId(), $group->getName(), $group->isSuper() ? '<info>Yes</info>' : 'No'); }, $users)); $table->render(); }
protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->container->getDoctrine()->getManager($input->getOption('em')); $users = $em->getRepository('CmsAuthentication:User')->findBy(array(), array('login' => 'ASC')); $table = new Table($output); $table->setHeaders(array('ID', 'Login', 'Email', 'Groups', 'Active')); $table->addRows(array_map(function ($user) { /* @var $user User */ return array($user->getId(), $user->getLogin(), $user->getEmail(), call_user_func(function ($value) { if ($value instanceof Group) { return $value->getName(); } else { return '--/--'; } }, $user->getGroup()), $user->isActive() ? '<info>Yes</info>' : 'No'); }, $users)); $table->render(); }
protected function execute(InputInterface $input, OutputInterface $output) { $rating = $this->nflHandler->getRating(); $output->writeln(sprintf("<info>Rating dates:: [%s - %s]</info>", $rating["start_date"], $rating["end_date"])); $table = new Table($output); $table->setHeaders(array('Game', 'Rating', 'Predict'))->setStyle('borderless')->addRow(array(new TableCell('<error>Finished games</error>', array('colspan' => 3)))); $output->writeln("<error>Finished games</error>"); foreach ($rating["finished"] as $game) { $table->addRow(array(sprintf("%s @ %s", $game["away_team"], $game["home_team"]), $game["gex"], $game["gex_predict"])); } $table->addRows(array(new TableSeparator(), array(new TableCell('<error>Future games</error>', array('colspan' => 3))))); $output->writeln(""); $output->writeln("<error>Future games</error>"); foreach ($rating["future"] as $game) { $table->addRow(array(sprintf("%s @ %s", $game["away_team"], $game["home_team"]), "", $game["gex_predict"])); } $table->render(); }
protected function execute(InputInterface $input, OutputInterface $output) { $keys = $this->getClient()->getSshKeys(); if (empty($keys)) { $this->stdErr->writeln("You do not yet have any SSH public keys in your Platform.sh account"); } else { $this->stdErr->writeln("Your SSH keys are:"); $table = new Table($output); $headers = array('ID', 'Title', 'Fingerprint'); $rows = array(); foreach ($keys as $key) { $rows[] = array($key['key_id'], $key['title'], $key['fingerprint']); } $table->setHeaders($headers); $table->addRows($rows); $table->render(); } $this->stdErr->writeln(''); $this->stdErr->writeln("Add a new SSH key by running <info>platform ssh-key:add [path]</info>"); $this->stdErr->writeln("Delete an SSH key by running <info>platform ssh-key:delete [id]</info>"); }
public function addRows(array $rows) { $this->table->addRows($rows); return $this; }
/** * @param OutputInterface $output * @param $modules */ protected function ouputResult(OutputInterface $output, $modules) { $table = new Table($output); $table->setHeaders(array('Vendor', 'Title', 'Version', 'Is Enabled', 'Is Output Enabled')); $table->addRows($modules); $table->render(); }
/** * @param InputInterface $input * @param OutputInterface $output */ protected function printEnvironmentReport(InputInterface $input, OutputInterface $output) { /** @var CronReport $report */ $report = $this->getContainer()->get('babymarkt_ext_cron.service.cronreport'); $result = $report->createEnvironmentReport(); if ($input->getOption('json')) { $output->writeln(json_encode($result)); } else { if (count($result)) { $table = new Table($output); $table->setHeaders(['Alias', 'Command', 'Count', 'Avg', 'Min', 'Max', 'Total', 'Last run', 'Failed count', 'Last failed']); $table->addRows($result); $table->render(); } else { $this->printNoRecords($output, $report->getEnvironment()); } } }
/** * @param InputInterface $input * @param OutputInterface $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $helper = new Table($output); $helper->addRows($this->getModulesData()); $helper->setHeaders(["Code", "Active", "Type", "Version"])->render(); }