Last active
December 18, 2019 16:18
-
-
Save foaly-nr1/3c53513643402cfb85fdb43b3d890d81 to your computer and use it in GitHub Desktop.
Pac Man style ProgressBar in Symfony command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Command; | |
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | |
use Symfony\Component\Console\Helper\ProgressBar; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
class PacManCommand extends ContainerAwareCommand | |
{ | |
const COMMAND_NAME = 'app:pacman'; | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function configure() | |
{ | |
$this | |
->setName(self::COMMAND_NAME) | |
->setDescription('Eat all pac-dots') | |
; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$progress = new ProgressBar($output, 10); | |
$progress->setProgressCharacter('ᗧ'); | |
$progress->setEmptyBarCharacter('·'); | |
$progress->start(); | |
// ... | |
} | |
} |
Author
foaly-nr1
commented
Nov 25, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment