diff --git a/Command/WurstCommand.php b/Command/WurstCommand.php index 9be7203..f82ff2c 100644 --- a/Command/WurstCommand.php +++ b/Command/WurstCommand.php @@ -1,101 +1,101 @@ - - */ -class WurstCommand extends ContainerAwareCommand -{ - const ERROR_WURST_NOT_FOUND = 1; - - protected $wurstTypes = array(); - - public function __construct($name = null) - { - $finder = Finder::create() - ->in(__DIR__.'/../Resources/wurst') - ->name('*.txt') - ->depth(0) - ->filter(function (SplFileInfo $file) { - return $file->isReadable(); - }) - ; - - foreach ($finder as $file) { - $this->wurstTypes[] = basename($file->getRelativePathName(), '.txt'); - } - - parent::__construct($name); - } - - protected function configure() - { - $this - ->setName('wurst:print') - ->addOption('mit-pommes', null, InputOption::VALUE_NONE, 'Mit Pommes?') - ->addOption('mit-mayo', null, InputOption::VALUE_NONE, 'Mit Mayo?') - ->addOption('mit-beer', null, InputOption::VALUE_NONE, 'Mit Beer?') - ->addOption('mit-pretzel', null, InputOption::VALUE_NONE, 'Mit Pretzel?') - ->addOption('mit-kaffee', null, InputOption::VALUE_NONE, 'Mit Kaffee?') - ->addOption('mit-kase', null, InputOption::VALUE_NONE, 'Mit Kase?') - ->addArgument('type', null, sprintf('Which type of würst you want (%s)?', implode(', ', $this->wurstTypes)), 'classic') - ->setHelp('Please ask your local curry würst retailer.') - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $wurstFile = sprintf(__DIR__.'/../Resources/wurst/%s.txt', $input->getArgument('type')); - if (!is_readable($wurstFile)) { - $output->writeln(sprintf( - 'This würst is not part of this bundle. Try one of "%s" or consider contributing!', - implode(', ', $this->wurstTypes) - )); - - return self::ERROR_WURST_NOT_FOUND; - } - - $wurst = file_get_contents($wurstFile); - $output->writeln($wurst); - - if ($input->getOption('mit-pommes')) { - $pommes = file_get_contents(__DIR__.'/../Resources/sides/pommes.txt'); - $output->write($pommes); - } - - if ($input->getOption('mit-mayo')) { - $mayo = file_get_contents(__DIR__.'/../Resources/sides/mayonnaise.txt'); - $output->write($mayo); - } - - if ($input->getOption('mit-beer')) { - $beer = file_get_contents(__DIR__.'/../Resources/sides/beer.txt'); - $output->write($beer); - } - - if ($input->getOption('mit-pretzel')) { - $pretzel = file_get_contents(__DIR__.'/../Resources/sides/pretzel.txt'); - $output->write($pretzel); - } - - if ($input->getOption('mit-kaffee')) { - $kaffee = file_get_contents(__DIR__.'/../Resources/sides/kaffee.txt'); - $output->write($kaffee); - } - - if ($input->getOption('mit-kase')) { - $kase = file_get_contents(__DIR__.'/../Resources/sides/kase.txt'); - $output->write($kase); - } - } -} + + */ +class WurstCommand extends ContainerAwareCommand +{ + const ERROR_WURST_NOT_FOUND = 1; + + protected $wurstTypes = array(); + + public function __construct($name = null) + { + $finder = Finder::create() + ->in(__DIR__.'/../Resources/wurst') + ->name('*.txt') + ->depth(0) + ->filter(function (SplFileInfo $file) { + return $file->isReadable(); + }) + ; + + foreach ($finder as $file) { + $this->wurstTypes[] = basename($file->getRelativePathName(), '.txt'); + } + + parent::__construct($name); + } + + protected function configure() + { + $this + ->setName('wurst:print') + ->addOption('mit-pommes', null, InputOption::VALUE_NONE, 'Mit Pommes?') + ->addOption('mit-mayonnaise', null, InputOption::VALUE_NONE, 'Mit Mayonnaise?') + ->addOption('mit-beer', null, InputOption::VALUE_NONE, 'Mit Beer?') + ->addOption('mit-pretzel', null, InputOption::VALUE_NONE, 'Mit Pretzel?') + ->addOption('mit-coffee', null, InputOption::VALUE_NONE, 'Mit Coffee?') + ->addOption('mit-kase', null, InputOption::VALUE_NONE, 'Mit Kase?') + ->addArgument('type', null, sprintf('Which type of würst you want (%s)?', implode(', ', $this->wurstTypes)), 'classic') + ->setHelp('Please ask your local curry würst retailer.') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $wurstFile = sprintf(__DIR__.'/../Resources/wurst/%s.txt', $input->getArgument('type')); + if (!is_readable($wurstFile)) { + $output->writeln(sprintf( + 'This würst is not part of this bundle. Try one of "%s" or consider contributing!', + implode(', ', $this->wurstTypes) + )); + + return self::ERROR_WURST_NOT_FOUND; + } + + $wurst = file_get_contents($wurstFile); + $output->writeln($wurst); + + if ($input->getOption('mit-pommes')) { + $pommes = file_get_contents(__DIR__.'/../Resources/sides/pommes.txt'); + $output->write($pommes); + } + + if ($input->getOption('mit-mayonnaise')) { + $mayo = file_get_contents(__DIR__.'/../Resources/sides/mayonnaise.txt'); + $output->write($mayo); + } + + if ($input->getOption('mit-beer')) { + $beer = file_get_contents(__DIR__.'/../Resources/sides/beer.txt'); + $output->write($beer); + } + + if ($input->getOption('mit-pretzel')) { + $pretzel = file_get_contents(__DIR__.'/../Resources/sides/pretzel.txt'); + $output->write($pretzel); + } + + if ($input->getOption('mit-coffee')) { + $kaffee = file_get_contents(__DIR__.'/../Resources/sides/coffee.txt'); + $output->write($kaffee); + } + + if ($input->getOption('mit-kase')) { + $kase = file_get_contents(__DIR__.'/../Resources/sides/kase.txt'); + $output->write($kase); + } + } +}