From 2cd2cb04802cb764eb2be440dccb31d7f96fff5c Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 18 Sep 2015 10:27:23 -0600 Subject: [PATCH] added `-y` option to `bin/gpm update` #333 --- system/src/Grav/Console/Gpm/UpdateCommand.php | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php index eef10039b..79517300f 100644 --- a/system/src/Grav/Console/Gpm/UpdateCommand.php +++ b/system/src/Grav/Console/Gpm/UpdateCommand.php @@ -69,6 +69,12 @@ class UpdateCommand extends Command 'The grav instance location where the updates should be applied to. By default this would be where the grav cli has been launched from', GRAV_ROOT ) + ->addOption( + 'all-yes', + 'y', + InputOption::VALUE_NONE, + 'Assumes yes (or best approach) instead of prompting' + ) ->addArgument( 'package', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, @@ -90,6 +96,7 @@ class UpdateCommand extends Command $this->gpm = new GPM($this->input->getOption('force')); $this->destination = realpath($this->input->getOption('destination')); + $skip_prompt = $this->input->getOption('all-yes'); if (!Installer::isGravInstance($this->destination)) { $this->output->writeln("ERROR: " . Installer::lastErrorMsg()); @@ -136,19 +143,21 @@ class UpdateCommand extends Command } } - // prompt to continue - $this->output->writeln(""); - $questionHelper = $this->getHelper('question'); - $question = new ConfirmationQuestion("Continue with the update process? [Y|n] ", true); - $answer = $questionHelper->ask($this->input, $this->output, $question); + if (!$skip_prompt) { + // prompt to continue + $this->output->writeln(""); + $questionHelper = $this->getHelper('question'); + $question = new ConfirmationQuestion("Continue with the update process? [Y|n] ", true); + $answer = $questionHelper->ask($this->input, $this->output, $question); - if (!$answer) { - $this->output->writeln("Update aborted. Exiting..."); - exit; + if (!$answer) { + $this->output->writeln("Update aborted. Exiting..."); + exit; + } } // finally update - $installCommand = $this->getApplication()->find('install'); + $install_command = $this->getApplication()->find('install'); $args = new ArrayInput(array( 'command' => 'install',