From 54c46d91d3568a6b77431b650685b21a62694139 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sat, 2 Sep 2017 18:32:56 -0400 Subject: [PATCH 1/4] Handle --yes and --debug. --- src/Application.php | 19 ++++++++++++++++--- src/Preflight/Preflight.php | 10 ++++++++++ src/Style/DrushStyle.php | 16 ---------------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/Application.php b/src/Application.php index eab28e0818..d12ca2110b 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,9 @@ public function __construct($name, $version) // --verbose / -v // --help // --quiet + // --debug / -d : equivalent to -vv + // --yes / -y : equivalent to --no-interaction + // // // No longer supported // @@ -57,9 +60,8 @@ public function __construct($name, $version) // // Not handled yet (to be implemented): // - // --debug / -d + // --uri / -l - // --yes / -y // --pipe // --php // --php-options @@ -86,6 +88,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..1bdf708409 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_VERBOSE); + } + // 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; - } } From 63b967228e94d5e0aa1b1c873c1c83bbe83aecb4 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sat, 2 Sep 2017 18:55:35 -0400 Subject: [PATCH 2/4] Move php and php-options options to 'no longer supported' --- src/Application.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Application.php b/src/Application.php index d12ca2110b..81bb3f224b 100644 --- a/src/Application.php +++ b/src/Application.php @@ -45,6 +45,7 @@ public function __construct($name, $version) // --quiet // --debug / -d : equivalent to -vv // --yes / -y : equivalent to --no-interaction + // --nocolor : equivalent to --no-ansi // // // No longer supported @@ -57,14 +58,14 @@ 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 + // --php-options // // Not handled yet (to be implemented): // // --uri / -l // --pipe - // --php - // --php-options // --tty // --exclude // --backend @@ -72,7 +73,6 @@ public function __construct($name, $version) // --ignored-modules // --no-label // --label-separator - // --nocolor // --cache-default-class // --cache-class- // --confirm-rollback From f87b2ed1689369acd469f19e9a8e9ec471ad85b4 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sat, 2 Sep 2017 23:02:05 -0400 Subject: [PATCH 3/4] Deprecate pipe. Explicit formats are better IMO. --- src/Application.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Application.php b/src/Application.php index 81bb3f224b..898cf32484 100644 --- a/src/Application.php +++ b/src/Application.php @@ -58,14 +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 + // --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): // // --uri / -l - // --pipe // --tty // --exclude // --backend From 5b274823ee12e0f7334db6597404f5084cde57c7 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sun, 3 Sep 2017 09:04:37 -0400 Subject: [PATCH 4/4] Change constant. --- src/Preflight/Preflight.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Preflight/Preflight.php b/src/Preflight/Preflight.php index 1bdf708409..0a82bd80d5 100644 --- a/src/Preflight/Preflight.php +++ b/src/Preflight/Preflight.php @@ -206,7 +206,7 @@ protected function doRun($argv) } // Use -vvv for even more verbose logging. if ($input->getParameterOption(['--debug', '-d'], false, true)) { - $output->setVerbosity(Output::VERBOSITY_VERBOSE); + $output->setVerbosity(Output::VERBOSITY_DEBUG); } // Run the Symfony Application