setName('streams') ->setDescription('List available streams.') ->addOption('category', null, InputOption::VALUE_REQUIRED, '') ->setHelp("The %command.name% lists live streams"); } protected function execute(InputInterface $input, OutputInterface $output) { $liveCoding = $this->getApplication()->getContainer()['livecoding']; try { $streams = $liveCoding->getStreams(); foreach ($streams as $stream) { $output->writeln(sprintf( '%s', $stream->getTitle() )); $output->writeln(sprintf( '%s', str_repeat('-', mb_strlen($stream->getTitle())) )); $output->writeln(sprintf( 'Author: %s', $stream->getAuthor() )); if (count($stream->getLanguages())) { $output->writeln(sprintf( 'Languages: %s', implode(', ', $stream->getLanguages()) )); $output->writeln(sprintf( 'Difficulty: %s', $stream->getDifficulty() )); } $output->writeln(sprintf( 'URL: %s', $stream->getUrl() )); $output->writeln(sprintf( 'Views: %d', $stream->getViews() )); $output->writeln(''); } } catch (Exception $e) { $output->writeln(sprintf('%s', $e->getMessage())); } } }