diff --git a/src/Application.php b/src/Application.php index eab28e0818..898cf32484 100644 --- a/src/Application.php +++ b/src/Application.php @@ -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 @@ -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 // @@ -54,15 +58,13 @@ 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 @@ -70,7 +72,6 @@ public function __construct($name, $version) // --ignored-modules // --no-label // --label-separator - // --nocolor // --cache-default-class // --cache-class- // --confirm-rollback @@ -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.') diff --git a/src/Preflight/Preflight.php b/src/Preflight/Preflight.php index 792cab74d1..0a82bd80d5 100644 --- a/src/Preflight/Preflight.php +++ b/src/Preflight/Preflight.php @@ -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; @@ -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) diff --git a/src/Style/DrushStyle.php b/src/Style/DrushStyle.php index c99399f35b..ff12e83f27 100644 --- a/src/Style/DrushStyle.php +++ b/src/Style/DrushStyle.php @@ -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; - } }