*/ class ListCommand extends Command { /** * {@inheritdoc} */ protected function configure() { $this ->setName('list') ->setDescription('List gists using the API'); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $gists = $this->getSilexApplication()['api_client']->list(); $rows = []; foreach ($gists as $gist) { $rows[] = array( $gist['id'], $gist['title'], $gist['cipher'] ? 'y' : 'n', $gist['type'], (new DateTime($gist['createdAt']))->format('Y-m-d H:i:s'), (new DateTime($gist['updatedAt']))->format('Y-m-d H:i:s'), $gist['url'], ); } $table = new Table($output); $table ->setHeaders(array('ID', 'Title', 'Cipher', 'Type', 'Created At', 'Updated At', 'url')) ->setRows($rows); $table->render(); } }