本文整理匯總了PHP中Symfony\Component\Console\Input\InputInterface::getOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP InputInterface::getOptions方法的具體用法?PHP InputInterface::getOptions怎麽用?PHP InputInterface::getOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Input\InputInterface
的用法示例。
在下文中一共展示了InputInterface::getOptions方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$options = $input->getOptions();
if ($input->getArgument('test')) {
$options['steps'] = true;
}
$suite = $input->getArgument('suite');
$test = $input->getArgument('test');
$codecept = new \Codeception\Codecept((array) $options);
$suites = $suite ? array($suite) : \Codeception\Configuration::suites();
$output->writeln(\Codeception\Codecept::versionString() . "\nPowered by " . \PHPUnit_Runner_Version::getVersionString());
if ($suite and $test) {
$codecept->runSuite($suite, $test);
}
if (!$test) {
foreach ($suites as $suite) {
$codecept->runSuite($suite);
}
}
$codecept->printResult();
if (!$input->getOption('no-exit')) {
if ($codecept->getResult()->failureCount() or $codecept->getResult()->errorCount()) {
exit(1);
}
}
}
示例2: option
/**
* Get the value of a command option.
*
* @param string $key
* @return string|array
*/
public function option($key = null)
{
if (is_null($key)) {
return $this->input->getOptions();
}
return $this->input->getOption($key);
}
示例3: interact
protected function interact(InputInterface $input, OutputInterface $output)
{
// if (!$input->getOption('init'))
return;
$options = array($this->getDefinition()->getOption('website-name'), $this->getDefinition()->getOption('web-source-dir'), $this->getDefinition()->getOption('web-prod-dir'), $this->getDefinition()->getOption('web-user'), $this->getDefinition()->getOption('exclude-file'), $this->getDefinition()->getOption('include-file'), $this->getDefinition()->getOption('backup-sources'), $this->getDefinition()->getOption('backup-destination'), $this->getDefinition()->getOption('db-name'), $this->getDefinition()->getOption('db-user'), $this->getDefinition()->getOption('db-pass'));
$dialog = $this->getDialogHelper();
foreach ($options as $option) {
$name = $option->getName();
$value = $input->getOption($name);
if (!$value) {
$value = $option->getDefault();
}
$value = $dialog->ask($output, $dialog->getQuestion($name, $value), $value);
if ($option->isArray()) {
$array = array($value);
while ('y' == $dialog->ask($output, $dialog->getQuestion('Do you want to add another?', 'Y/n'), 'y')) {
$temp = $dialog->ask($output, $dialog->getQuestion($name, null), null);
if (!is_null($temp)) {
$array[] = $temp;
}
}
$value = $array;
}
$input->setOption($name, $value);
}
fputs(fopen('../config2.yml', 'w'), Yaml::dump($input->getOptions()));
}
示例4: execute
/**
* Execute command
*
* @param InputInterface $input
* @param OutputInterface $output
* @throws \RuntimeException
* @return null
*/
public function execute(InputInterface $input, OutputInterface $output)
{
// checking config
if ($this->isConfigExist() === false) {
throw new \RuntimeException('Configuration file does not exist! Run `xmail init`');
}
// get requested data
$request = $input->getOptions();
$serviceManager = $this->getAppServiceManager();
foreach ($request['queues'] as $queue) {
$this->logOutput($output, sprintf($this->prompt['START_PROCESS'], $queue['pid'], $request['subscribersTotal']), "<bg=white;options=bold>%s</>");
// get queue by process id
$serviceManager->getQueueData($queue['pid'], function ($processData) use($output, $request, $serviceManager) {
foreach ($processData as $data) {
// create progress instance with total of subscribers
$progress = $this->getProgress($output, $request['subscribersTotal'], 'debug');
$progress->start();
$i = 0;
while ($i++ < $request['subscribersTotal']) {
// send message
$serviceManager->sendMessage($request['subscribers'][$i], $data);
$progress->advance();
}
$progress->finish();
$progress->getMessage();
$this->logOutput($output, sprintf($this->prompt['DONE_PROCESS'], $data['list_id']), " <bg=white;options=bold>%s</>");
}
});
// remove waste processes from storage
$serviceManager->removeQueue($queue['pid']);
}
// final message
$this->logOutput($output, $this->prompt['DONE_ALL'], "<fg=white;bg=magenta>%s</fg=white;bg=magenta>");
}
示例5: execute
/**
* Executes the current command.
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return integer 0 if everything went fine, or an error code
*
* @throws \LogicException When this abstract class is not implemented
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// check command is valid
$call = strtolower($input->getArgument('call'));
$argStr = $input->getArgument('args');
$options = $input->getOptions();
parse_str($argStr, $args);
$apiclient = $this->getClient();
/* @var $apiclient \ServerGrove\APIClient */
if ($options['url']) {
$apiclient->setUrl($options['url']);
}
if ($options['verbose']) {
$output->writeln("Calling: <info>" . $apiclient->getFullUrl($call, $args) . "</info>");
}
if ($apiclient->call($call, $args)) {
if ($options['verbose']) {
$output->writeln("Response: <info>" . print_r($apiclient->getResponse(), true) . "</info>");
} else {
$output->writeln($apiclient->getRawResponse());
}
return 0;
} else {
if ($options['verbose']) {
$output->writeln("<error>" . $apiclient->getError() . "</error>");
} else {
$output->writeln($apiclient->getRawResponse());
}
return 1;
}
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var ApplicationInterface $application */
$application = $this->getContainer()->get('net_tomas_kadlec_d2s.service.application');
$outputFormat = $input->getOption('output');
if (!$application->isOutput($outputFormat)) {
throw new \RuntimeException('Supported output formats: ' . join(', ', $application->getOutputs()));
}
// output options (prefixed with $outputFormat)
$options = [];
foreach ($input->getOptions() as $option => $value) {
if (preg_match("/^{$outputFormat}-/", $option)) {
$option = preg_replace("/^{$outputFormat}-/", '', $option);
if (!empty($value)) {
$options[$option] = $value;
}
}
}
if ($input->getOption('all')) {
$restaurantIds = $application->getRestaurants();
} else {
$restaurantIds = $input->getArgument('restaurants');
if (empty($restaurantIds)) {
throw new \RuntimeException('Provide one restaurant ID at least or use --all option');
}
}
foreach ($restaurantIds as $restaurantId) {
if (!$application->isRestaurant($restaurantId)) {
continue;
}
$application->output($restaurantId, $outputFormat, $options);
}
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->directory = getcwd();
$this->package = strtolower($input->getArgument('package'));
if (!in_array($this->package, $this->packages)) {
throw new RuntimeException('The package does not exist!');
}
$output->writeln('<info>Crafting application...</info>');
if (!in_array(1, $input->getOptions()) || $input->getOption("all")) {
$this->all($input, $output);
} else {
if ($input->getOption("models")) {
$this->models($input, $output);
}
if ($input->getOption("views")) {
$this->views($input, $output);
}
if ($input->getOption("controllers")) {
$this->controllers($input, $output);
}
if ($input->getOption("libraries")) {
$this->library($input, $output);
}
}
$output->writeln("All Done");
}
示例8: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$suiteName = $input->getArgument('suite');
$this->output = $output;
$config = \Codeception\Configuration::config($input->getOption('config'));
$settings = \Codeception\Configuration::suiteSettings($suiteName, $config);
$options = $input->getOptions();
$options['debug'] = true;
$options['steps'] = true;
$this->codecept = new \Codeception\Codecept($options);
$dispatcher = $this->codecept->getDispatcher();
$suiteManager = new SuiteManager($dispatcher, $suiteName, $settings);
$this->suite = $suiteManager->getSuite();
$this->test = new Cept($dispatcher, array('name' => 'interactive', 'file' => 'interactive'));
$guy = $settings['class_name'];
$scenario = new Scenario($this->test);
$I = new $guy($scenario);
$this->listenToSignals();
$output->writeln("<info>Interactive console started for suite {$suiteName}</info>");
$output->writeln("<info>Try Codeception commands without writing a test</info>");
$output->writeln("<info>type 'exit' to leave console</info>");
$output->writeln("<info>type 'actions' to see all available actions for this suite</info>");
$dispatcher->dispatch('suite.before', new Suite($this->suite, $this->codecept->getResult(), $settings));
$dispatcher->dispatch('test.parsed', new \Codeception\Event\Test($this->test));
$dispatcher->dispatch('test.before', new \Codeception\Event\Test($this->test));
$output->writeln("\n\n\$I = new {$settings['class_name']}(\$scenario);");
$scenario->run();
$this->executeCommands($output, $I, $settings['bootstrap']);
$dispatcher->dispatch('test.after', new \Codeception\Event\Test($this->test));
$dispatcher->dispatch('suite.after', new Suite($this->suite));
$output->writeln("<info>Bye-bye!</info>");
}
示例9: install
protected function install(InputInterface $input, OutputInterface $output)
{
$options = $input->getOptions();
$composer = isset($options['composer']) ? $options['composer'] : 'composer';
$this->installDependencies(getcwd(), $output, $composer);
$this->installMigrations($output, $composer);
}
示例10: getSymfonyCommandOptions
protected function getSymfonyCommandOptions(InputInterface $input)
{
$commandOptions = [];
foreach ($input->getOptions() as $name => $value) {
if ($value === false) {
continue;
}
switch ($name) {
case 'symfony-env':
case 'verbose':
case 'profile':
case 'working-dir':
case 'project-name':
case 'cache-dir':
break;
default:
if ($value === true) {
$commandOptions[] = sprintf('--%s', $name);
continue;
}
if (!empty($value)) {
$commandOptions[] = sprintf('--%s=%s', $name, $value);
}
break;
}
}
return $commandOptions;
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getHelperSet()->get('dialog');
$whitelist = array('name', 'description', 'author', 'require');
$options = array_filter(array_intersect_key($input->getOptions(), array_flip($whitelist)));
if (isset($options['author'])) {
$options['authors'] = $this->formatAuthors($options['author']);
unset($options['author']);
}
$options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass();
$file = new JsonFile('composer.json');
$json = $file->encode($options);
if ($input->isInteractive()) {
$output->writeln(array('', $json, ''));
if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
$file->write($options);
if ($input->isInteractive()) {
$ignoreFile = realpath('.gitignore');
if (false === $ignoreFile) {
$ignoreFile = realpath('.') . '/.gitignore';
}
if (!$this->hasVendorIgnore($ignoreFile)) {
$question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]?';
if ($dialog->askConfirmation($output, $question, true)) {
$this->addVendorIgnore($ignoreFile);
}
}
}
}
示例12: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->factory = $this->getContainer()->get('mautic.factory');
$queueMode = $this->factory->getParameter('queue_mode');
// check to make sure we are in queue mode
if ($queueMode != 'command_process') {
$output->writeLn('Webhook Bundle is in immediate process mode. To use the command function change the command mode.');
return 0;
}
$options = $input->getOptions();
/** @var \Mautic\WebhookBundle\Model\WebhookModel $model */
$model = $this->factory->getModel('webhook.webhook');
// make sure we only get published webhook entities
$webhooks = $model->getEntities(array('filter' => array('force' => array(array('column' => 'e.isPublished', 'expr' => 'eq', 'value' => 1)))));
if (!count($webhooks)) {
$output->writeln('<error>No published webhooks found. Try again later.</error>');
return;
}
$output->writeLn('<info>Processing Webhooks</info>');
try {
$model->processWebhooks($webhooks);
} catch (\Exception $e) {
$output->writeLn('<error>' . $e->getMessage() . '</error>');
}
$output->writeLn('<info>Webhook Processing Complete</info>');
}
示例13: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$options = array_merge($input->getArguments(), $input->getOptions());
var_dump($options);
$this->getClient()->updateAutoScalingGroup($options);
return self::COMMAND_SUCCESS;
}
示例14: setupStep
/**
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function setupStep(InputInterface $input, OutputInterface $output)
{
$output->writeln('<info>Setting up database.</info>');
$dialog = $this->getHelperSet()->get('dialog');
$container = $this->getContainer();
$options = $input->getOptions();
$input->setInteractive(false);
$this->runCommand('oro:entity-extend:clear', $input, $output)->runCommand('doctrine:schema:drop', $input, $output, array('--force' => true, '--full-database' => true))->runCommand('doctrine:schema:create', $input, $output)->runCommand('oro:entity-config:init', $input, $output)->runCommand('oro:entity-extend:init', $input, $output)->runCommand('oro:entity-extend:update-config', $input, $output, array('--process-isolation' => true))->runCommand('doctrine:schema:update', $input, $output, array('--process-isolation' => true, '--force' => true, '--no-interaction' => true))->runCommand('doctrine:fixtures:load', $input, $output, array('--process-isolation' => true, '--no-interaction' => true, '--append' => true));
$output->writeln('');
$output->writeln('<info>Administration setup.</info>');
$user = $container->get('oro_user.manager')->createUser();
$role = $container->get('doctrine.orm.entity_manager')->getRepository('OroUserBundle:Role')->findOneBy(array('role' => 'ROLE_ADMINISTRATOR'));
$businessUnit = $container->get('doctrine.orm.entity_manager')->getRepository('OroOrganizationBundle:BusinessUnit')->findOneBy(array('name' => 'Main'));
$passValidator = function ($value) {
if (strlen(trim($value)) < 2) {
throw new \Exception('The password must be at least 2 characters long');
}
return $value;
};
$userName = isset($options['user-name']) ? $options['user-name'] : $dialog->ask($output, '<question>Username:</question> ');
$userEmail = isset($options['user-email']) ? $options['user-email'] : $dialog->ask($output, '<question>Email:</question> ');
$userFirstName = isset($options['user-firstname']) ? $options['user-firstname'] : $dialog->ask($output, '<question>First name:</question> ');
$userLastName = isset($options['user-lastname']) ? $options['user-lastname'] : $dialog->ask($output, '<question>Last name:</question> ');
$userPassword = isset($options['user-password']) ? $options['user-password'] : $dialog->askHiddenResponseAndValidate($output, '<question>Password:</question> ', $passValidator);
$user->setUsername($userName)->setEmail($userEmail)->setFirstName($userFirstName)->setLastName($userLastName)->setPlainPassword($userPassword)->setEnabled(true)->addRole($role)->setOwner($businessUnit)->addBusinessUnit($businessUnit);
$container->get('oro_user.manager')->updateUser($user);
$demo = isset($options['sample-data']) ? strtolower($options['sample-data']) == 'y' : $dialog->askConfirmation($output, '<question>Load sample data (y/n)?</question> ', false);
// load demo fixtures
if ($demo) {
$this->runCommand('oro:demo:fixtures:load', $input, $output, array('--process-isolation' => true, '--process-timeout' => 300));
}
$output->writeln('');
return $this;
}
示例15: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$config = new Config();
$config->setBasePath(getcwd());
$config->setFromArray($input->getArguments());
$config->setFromArray($input->getOptions());
$moduleConfig = new ConfigWriter($config);
$state = new State($moduleConfig);
$builder = new OptionsContainer($config);
$builder->addBuilder(new ExceptionContainer($config));
$builder->prepare($state);
$builder->build($state);
$writeState = new State($moduleConfig);
$models = array('options' => $state->getModel('options'), 'factory' => $state->getModel('options-factory'), 'trait' => $state->getModel('options-trait'));
foreach (array_keys($models) as $key) {
if ($input->getOption('no-' . $key)) {
$models[$key] = false;
}
if ($input->getOption('only-' . $key)) {
foreach (array_keys($models) as $index) {
if ($key != $index) {
$models[$index] = false;
}
}
}
}
foreach ($models as $model) {
if ($model) {
$writeState->addModel($model);
}
}
$writer = new ModelWriter($config);
$writer->write($writeState, $output);
$moduleConfig->save($output);
}