Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle --yes and --debug #2927

Merged
merged 4 commits into from Sep 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 20 additions & 8 deletions src/Application.php
Expand Up @@ -30,7 +30,7 @@ public function __construct($name, $version)
// --alias-path
// --local
//
// Global options registerd with Symfony:
// Global options registered with Symfony:
//
// --remote-host
// --remote-user
Expand All @@ -43,6 +43,10 @@ public function __construct($name, $version)
// --verbose / -v
// --help
// --quiet
// --debug / -d : equivalent to -vv
// --yes / -y : equivalent to --no-interaction
// --nocolor : equivalent to --no-ansi
//
//
// No longer supported
//
Expand All @@ -54,23 +58,20 @@ public function __construct($name, $version)
// --strict Not supported by Symfony
// --interactive If command isn't -n, then it is interactive
// --command-specific Now handled by consolidation/config component
//
// --php If needed prefix command with PATH=/path/to/php:$PATH. Also see #env_vars in site aliases.
// --php-options
// --pipe
// Not handled yet (to be implemented):
//
// --debug / -d

// --uri / -l
// --yes / -y
// --pipe
// --php
// --php-options
// --tty
// --exclude
// --backend
// --choice
// --ignored-modules
// --no-label
// --label-separator
// --nocolor
// --cache-default-class
// --cache-class-<bin>
// --confirm-rollback
Expand All @@ -86,6 +87,17 @@ public function __construct($name, $version)
// --path-aliases
// --ssh-options


$this->getDefinition()
->addOption(
new InputOption('--debug', 'd', InputOption::VALUE_NONE, 'Equivalent to -vv')
);

$this->getDefinition()
->addOption(
new InputOption('--yes', 'y', InputOption::VALUE_NONE, 'Equivalent to --no-interaction.')
);

$this->getDefinition()
->addOption(
new InputOption('--remote-host', null, InputOption::VALUE_REQUIRED, 'Run on a remote server.')
Expand Down
10 changes: 10 additions & 0 deletions src/Preflight/Preflight.php
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\Output;
use Symfony\Component\Console\Output\OutputInterface;

use Webmozart\PathUtil\Path;
Expand Down Expand Up @@ -199,6 +200,15 @@ protected function doRun($argv)
$runner = new \Robo\Runner();
$runner->registerCommandClasses($application, $commandClasses);

// Process legacy Drush global options.
if ($input->getParameterOption(['--yes', '-y'], false, true)) {
$input->setInteractive(false);
}
// Use -vvv for even more verbose logging.
if ($input->getParameterOption(['--debug', '-d'], false, true)) {
$output->setVerbosity(Output::VERBOSITY_DEBUG);
}

// Run the Symfony Application
// Predispatch: call a remote Drush command if applicable (via a 'pre-init' hook)
// Bootstrap: bootstrap site to the level requested by the command (via a 'post-init' hook)
Expand Down
16 changes: 0 additions & 16 deletions src/Style/DrushStyle.php
Expand Up @@ -26,20 +26,4 @@ public function choice($question, array $choices, $default = null)
return array_search($return, $choices);
}
}

public function confirm($question, $default = true)
{
// Automatically accept confirmations if the --yes argument was supplied.
if (drush_get_context('DRUSH_AFFIRMATIVE')) {
$this->comment($question . ': yes.');
return true;
} // Automatically cancel confirmations if the --no argument was supplied.
elseif (drush_get_context('DRUSH_NEGATIVE')) {
$this->warning($question . ': no.');
return false;
}

$return = parent::confirm($question, $default);
return $return;
}
}