public function testConstructor() { $callable = function () { }; $command = new Command('foo:bar', $callable); $this->assertEquals('foo:bar', $command->getName(), '__construct() takes the command name as its first argument'); }
/** * Creates a console application with all of the commands attached. * @return Application */ function createApplication() { // $rpmCommand = new Command('rpmdir', ['Bastion\RPMProcess', 'packageSingleDirectory']); // $rpmCommand->addArgument('directory', InputArgument::REQUIRED, "The directory containing the composer'd project to build into an RPM."); ////$uploadCommand->addOption('dir', null, InputArgument::OPTIONAL, 'Which directory to upload from', './'); // $rpmCommand->setDescription("Build an RPM from an directory that contains all the files of a project. Allows for faster testing than having to re-tag, and download zip files repeatedly."); $statsCommand = new Command('statsRunner', 'Stats\\SimpleStats::run'); $statsCommand->setDescription("Run the stats collector and send the results to Librato."); $taskCommand = new Command('imageRunner', 'ImagickDemo\\Queue\\ImagickTaskRunner::run'); $taskCommand->setDescription("Pull image request jobs off the queue and generated the images."); $clearCacheCommand = new Command('clearCache', 'ImagickDemo\\Config\\APCCacheEnvReader::clearCache'); $clearCacheCommand->setDescription("Clear the apc cache."); $envWriteCommand = new Command('genEnvSettings', 'ImagickDemo\\Config\\EnvConfWriter::writeEnvFile'); $envWriteCommand->setDescription("Write an env setting bash script."); $envWriteCommand->addArgument('env', InputArgument::REQUIRED, 'Which environment the settings should be generated for.'); $envWriteCommand->addArgument('filename', InputArgument::REQUIRED, 'The file name that the env settings should be written to.'); $clearRedisCommand = new Command('clearRedis', 'ImagickDemo\\Queue\\ImagickTaskQueue::clearStatusQueue'); $clearRedisCommand->setDescription("Clear the imagick task queue."); $console = new Application("ImagickDemos", "1.0.0"); $console->add($statsCommand); $console->add($taskCommand); $console->add($clearCacheCommand); $console->add($clearRedisCommand); $console->add($envWriteCommand); return $console; }
protected function setUp() { $callable = function (Output $output) { $output->writeln('foo'); }; $this->command = new Command('foo', $callable); $this->command->addArgument('command'); $this->command->addArgument('foo'); $this->tester = new CommandTester($this->command); $this->provider = new Provider(); $this->parsedCommand = $this->tester->execute(array('foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); }
/** * Creates a console application with all of the commands attached. * @return ConsoleApplication */ public function __construct() { parent::__construct("ImagickDemos", "1.0.0"); $statsCommand = new Command('statsRunner', 'Stats\\SimpleStats::run'); $statsCommand->setDescription("Run the stats collector and send the results to Librato."); $this->add($statsCommand); $taskCommand = new Command('imageRunner', 'ImagickDemo\\Queue\\ImagickTaskRunner::run'); $taskCommand->setDescription("Pull image request jobs off the queue and generated the images."); $this->add($taskCommand); $clearCacheCommand = new Command('clearCache', 'ImagickDemo\\Config\\APCCacheEnvReader::clearCache'); $clearCacheCommand->setDescription("Clear the apc cache."); $this->add($clearCacheCommand); $envWriteCommand = new Command('genEnvSettings', 'ImagickDemo\\Config\\EnvConfWriter::writeEnvFile'); $envWriteCommand->setDescription("Write an env setting bash script."); $envWriteCommand->addArgument('env', InputArgument::REQUIRED, 'Which environment the settings should be generated for.'); $envWriteCommand->addArgument('filename', InputArgument::REQUIRED, 'The file name that the env settings should be written to.'); $this->add($envWriteCommand); $clearRedisCommand = new Command('clearRedis', 'ImagickDemo\\Queue\\ImagickTaskQueue::clearStatusQueue'); $clearRedisCommand->setDescription("Clear the imagick task queue."); $this->add($clearRedisCommand); }
public function makeGenerateEnvCommand() { $configurateCommand = new Command(self::GENENV, ['Configurator\\Configurator', 'writeEnvironmentFile']); $configurateCommand->setDescription("Generate a list of env settings into a PHP file"); $configurateCommand->addArgument('input', InputArgument::REQUIRED, 'The input filename'); $configurateCommand->addArgument('output', InputArgument::REQUIRED, 'The output filename'); $configurateCommand->addArgument('environment', InputArgument::REQUIRED, 'What environment to generated the config for.'); $configurateCommand->addOption('phpsettings', 'p', InputArgument::OPTIONAL, 'A comma separated list of PHP setting files.'); $configurateCommand->addOption('jssettings', 'j', InputArgument::OPTIONAL, 'A comma separated list of JSON setting files.'); $configurateCommand->addOption('namespace', 'ns', InputArgument::OPTIONAL, 'An optional namespace for the env function.'); return $configurateCommand; }
function lowrey($params) { $newParams = []; foreach ($params as $key => $value) { $newParams[':' . $key] = $value; } return $newParams; } $console = new Application(); $console->add(new AboutCommand()); $uploadCommand = new Command('upload', 'uploadFile'); $uploadCommand->addArgument('filename', InputArgument::REQUIRED, 'The name of the file to upload'); $uploadCommand->addOption('dir', null, InputArgument::OPTIONAL, 'Which directory to upload from', './'); $console->add($uploadCommand); $helloWorldCallable = function ($name) { echo "Hello world, and particularly {$name}" . PHP_EOL; }; $callableCommand = new Command('greet', $helloWorldCallable); $callableCommand->addArgument('name', InputArgument::REQUIRED, 'The name of the person to say hello to.'); $callableCommand->setDescription("Says hello to the world and one named person"); $console->add($callableCommand); try { $parsedCommand = $console->parseCommandLine(); } catch (\Exception $e) { $output = new BufferedOutput(); $console->renderException($e, $output); echo $output->fetch(); exit(-1); } $provider = new Auryn\Provider(); $provider->execute($parsedCommand->getCallable(), lowrey($parsedCommand->getParams()));