Skip to content

Commit

Permalink
Handle --yes and --debug (#2927)
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzman committed Sep 3, 2017
1 parent 45d2449 commit b92831b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
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;
}
}

0 comments on commit b92831b

Please sign in to comment.