diff options
author | Victor Dubiniuk <victor.dubiniuk@gmail.com> | 2016-03-29 16:57:41 +0300 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2016-04-06 16:34:16 +0300 |
commit | b87b27cbd94275895fd9da3f29edced27cd5aaad (patch) | |
tree | 3a4b57968928b219bef50645fc883083055b9eb1 /core | |
parent | cfd8cc3fd8382038a556ea729bb7c9beb09e4765 (diff) |
Show hint in CLI
Diffstat (limited to 'core')
-rw-r--r-- | core/command/upgrade.php | 38 | ||||
-rw-r--r-- | core/register_command.php | 6 |
2 files changed, 41 insertions, 3 deletions
diff --git a/core/command/upgrade.php b/core/command/upgrade.php index c45984d7a30..c76c9be4ed8 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -30,6 +30,7 @@ namespace OC\Core\Command; use OC\Console\TimestampFormatter; +use OC\ReleaseNotes; use OC\Updater; use OCP\IConfig; use OCP\ILogger; @@ -37,8 +38,9 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Question\ConfirmationQuestion; -class Upgrade extends Command { +class Upgrade extends Base { const ERROR_SUCCESS = 0; const ERROR_NOT_INSTALLED = 1; @@ -53,17 +55,23 @@ class Upgrade extends Command { /** @var ILogger */ private $logger; + /** @var ReleaseNotes */ + private $releaseNotes; + /** * @param IConfig $config * @param ILogger $logger + * @param ReleaseNotes $releaseNotes */ - public function __construct(IConfig $config, ILogger $logger) { + public function __construct(IConfig $config, ILogger $logger, ReleaseNotes $releaseNotes) { parent::__construct(); $this->config = $config; $this->logger = $logger; + $this->releaseNotes = $releaseNotes; } protected function configure() { + parent::configure(); $this ->setName('upgrade') ->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.') @@ -95,6 +103,19 @@ class Upgrade extends Command { */ protected function execute(InputInterface $input, OutputInterface $output) { + if ($input->isInteractive()) { + $installedVersion = $this->config->getSystemValue('version', '0.0.0'); + $currentVersion = \OCP\Util::getVersion(); + + $releaseNotesArray = $this->releaseNotes->getReleaseNotes($installedVersion, $currentVersion); + if (!empty($releaseNotesArray)) { + $this->writeArrayInOutputFormat($input, $output, $releaseNotesArray); + if (!$this->ask($input, $output)){ + return self::ERROR_SUCCESS; + } + } + } + $simulateStepEnabled = true; $updateStepEnabled = true; $skip3rdPartyAppsDisable = false; @@ -262,4 +283,17 @@ class Upgrade extends Command { ); } } + + /** + * Ask for confirmation + * @param InputInterface $input + * @param OutputInterface $output + * @return bool + */ + public function ask(InputInterface $input, OutputInterface $output){ + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion('Continue with update (y/n)' . PHP_EOL, true); + return $helper->ask($input, $output, $question); + } + } diff --git a/core/register_command.php b/core/register_command.php index 17bd573133a..e06ff436f50 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -114,7 +114,11 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) { $application->add(new OC\Core\Command\Maintenance\Repair(new \OC\Repair(\OC\Repair::getRepairSteps()), \OC::$server->getConfig())); $application->add(new OC\Core\Command\Maintenance\SingleUser(\OC::$server->getConfig())); - $application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger())); + $application->add(new OC\Core\Command\Upgrade( + \OC::$server->getConfig(), + \OC::$server->getLogger(), + new \OC\ReleaseNotes(\OC::$server->getDatabaseConnection()) + )); $application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager())); $application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager())); |