Skip to content

Commit

Permalink
Fixed -y|--all-yes option for GPM::install - #985
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Aug 18, 2016
1 parent 84e6478 commit 613e985
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions system/src/Grav/Console/Gpm/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class InstallCommand extends ConsoleCommand
/** @var array */
protected $demo_processing = [];

protected $all_yes;

/**
*
*/
Expand Down Expand Up @@ -101,6 +103,8 @@ protected function serve()
{
$this->gpm = new GPM($this->input->getOption('force'));

$this->all_yes = $this->input->getOption('all-yes');

$this->displayGPMRelease();

$this->destination = realpath($this->input->getOption('destination'));
Expand Down Expand Up @@ -139,16 +143,22 @@ protected function serve()
unset($this->data['not_found']);
unset($this->data['total']);


if (isset($this->local_config)) {
// Symlinks available, ask if Grav should use them

$this->use_symlinks = false;
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion('Should Grav use the symlinks if available? [y|N] ', false);
if ($this->all_yes) {
$this->use_symlinks = false;
} else {
$this->use_symlinks = false;
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion('Should Grav use the symlinks if available? [y|N] ', false);

if ($helper->ask($this->input, $this->output, $question)) {
$this->use_symlinks = true;
if ($helper->ask($this->input, $this->output, $question)) {
$this->use_symlinks = true;
}
}

}

$this->output->writeln('');
Expand Down Expand Up @@ -197,10 +207,16 @@ protected function serve()
return false;
}

$helper = $this->getHelper('question');
$question = new ConfirmationQuestion("The package <cyan>$package_name</cyan> is already installed, overwrite? [y|N] ", false);
if ($this->all_yes) {
$answer = true;
} else {
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion("The package <cyan>$package_name</cyan> is already installed, overwrite? [y|N] ", false);

if ($helper->ask($this->input, $this->output, $question)) {
$answer = $helper->ask($this->input, $this->output, $question);
}

if ($answer) {
$is_update = true;
$this->processPackage($package, true, $is_update);
} else {
Expand Down Expand Up @@ -299,7 +315,13 @@ public function installDependencies($dependencies, $type, $message, $required =

$question = new ConfirmationQuestion("$questionAction $questionArticle $questionNoun? [Y|n] ", true);

if ($helper->ask($this->input, $this->output, $question)) {
if ($this->all_yes) {
$answer = true;
} else {
$answer = $helper->ask($this->input, $this->output, $question);
}

if ($answer) {
foreach ($packages as $dependencyName => $dependencyVersion) {
$package = $this->gpm->findPackage($dependencyName);
$this->processPackage($package, true, ($type == 'update') ? true : false);
Expand Down Expand Up @@ -561,10 +583,6 @@ private function checkDestination($package, $skip_prompt = false)
{
$question_helper = $this->getHelper('question');

if (!$skip_prompt) {
$skip_prompt = $this->input->getOption('all-yes');
}

Installer::isValidDestination($this->destination . DS . $package->install_path);

if (Installer::lastErrorCode() == Installer::EXISTS) {
Expand Down

0 comments on commit 613e985

Please sign in to comment.