/** * {@inheritdoc} */ public function handle(Args $args, IO $io, Command $command) { $application = $command->getApplication(); if ($args->isArgumentSet('command')) { $theCommand = $application->getCommand($args->getArgument('command')); $usage = new CommandHelp($theCommand); } else { $usage = new ApplicationHelp($application); } $usage->render($io); return 0; }
/** * {@inheritdoc} */ public function handle(Args $args, IO $io, Command $command) { $descriptor = new XmlDescriptor(); $output = new IOOutput($io); $application = $command->getApplication(); $applicationAdapter = new ApplicationAdapter($application); if ($args->isArgumentSet('command')) { $theCommand = $application->getCommand($args->getArgument('command')); $commandAdapter = new CommandAdapter($theCommand, $applicationAdapter); $descriptor->describe($output, $commandAdapter); } else { $descriptor->describe($output, $applicationAdapter); } return 0; }
public function handleInstall(Args $args, IO $io) { if ($args->isArgumentSet('server')) { $expr = Expr::same($args->getArgument('server'), AssetMapping::SERVER_NAME); $mappings = $this->assetManager->findAssetMappings($expr); } else { $mappings = $this->assetManager->getAssetMappings(); } if (!$mappings) { $io->writeLine('Nothing to install.'); return 0; } /** @var InstallationParams[] $paramsToInstall */ $paramsToInstall = array(); // Prepare and validate the installation of all matching mappings foreach ($mappings as $mapping) { $paramsToInstall[] = $this->installationManager->prepareInstallation($mapping); } foreach ($paramsToInstall as $params) { foreach ($params->getResources() as $resource) { $serverPath = rtrim($params->getDocumentRoot(), '/') . $params->getServerPathForResource($resource); $io->writeLine(sprintf('Installing <c1>%s</c1> into <c2>%s</c2> via <u>%s</u>...', $resource->getRepositoryPath(), trim($serverPath, '/'), $params->getInstallerDescriptor()->getName())); $this->installationManager->installResource($resource, $params); } } return 0; }
private function getPageName(Application $application, Args $args) { if ($args->isArgumentSet('command')) { $command = $application->getCommand($args->getArgument('command')); return $this->commandPagePrefix . $command->getName(); } if ($this->applicationPage) { return $this->applicationPage; } return $application->getConfig()->getName(); }
public function testIsArgumentSet() { $format = ArgsFormat::build()->addArgument(new Argument('argument1'))->addArgument(new Argument('argument2'))->getFormat(); $args = new Args($format); $this->assertFalse($args->isArgumentSet('argument1')); $this->assertFalse($args->isArgumentSet('argument2')); $this->assertFalse($args->isArgumentSet('foo')); $args->setArgument('argument1', 'value1'); $args->setArgument('argument2', 'value2'); $this->assertTrue($args->isArgumentSet('argument1')); $this->assertTrue($args->isArgumentSet('argument2')); $this->assertFalse($args->isArgumentSet('foo')); }