diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php
index 0ff0850bb..99f8bd2e2 100644
--- a/system/src/Grav/Console/Gpm/InfoCommand.php
+++ b/system/src/Grav/Console/Gpm/InfoCommand.php
@@ -5,6 +5,7 @@ use Grav\Common\GPM\GPM;
use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Question\ConfirmationQuestion;
/**
* Class InfoCommand
@@ -34,6 +35,12 @@ class InfoCommand extends ConsoleCommand
InputOption::VALUE_NONE,
'Force fetching the new data remotely'
)
+ ->addOption(
+ 'all-yes',
+ 'y',
+ InputOption::VALUE_NONE,
+ 'Assumes yes (or best approach) instead of prompting'
+ )
->addArgument(
'package',
InputArgument::REQUIRED,
@@ -107,9 +114,62 @@ class InfoCommand extends ConsoleCommand
}
}
+ $type = rtrim($foundPackage->package_type, 's');
+ $updatable = $this->gpm->{'is' . $type . 'Updatable'}($foundPackage->slug);
+ $installed = $this->gpm->{'is' . $type . 'Installed'}($foundPackage->slug);
+
+ // display current version if installed and different
+ if ($installed && $updatable) {
+ $local = $this->gpm->{'getInstalled'. $type}($foundPackage->slug);
+ $this->output->writeln('');
+ $this->output->writeln("Currently installed version: " . $local->version . "");
+ $this->output->writeln('');
+ }
+
+ // display changelog information
+ $questionHelper = $this->getHelper('question');
+ $skipPrompt = $this->input->getOption('all-yes');
+
+ if (!$skipPrompt) {
+ $question = new ConfirmationQuestion("Would you like to read the changelog? [y|N] ",
+ false);
+ $answer = $questionHelper->ask($this->input, $this->output, $question);
+
+ if ($answer) {
+ $changelog = $foundPackage->changelog;
+
+ $this->output->writeln("");
+ foreach ($changelog as $version => $log) {
+ $title = $version . ' [' . $log['date'] . ']';
+ $content = preg_replace_callback("/\d\.\s\[\]\(#(.*)\)/", function ($match) {
+ return "\n" . ucfirst($match[1]) . ":";
+ }, $log['content']);
+
+ $this->output->writeln(''.$title.'');
+ $this->output->writeln(str_repeat('-', strlen($title)));
+ $this->output->writeln($content);
+ $this->output->writeln("");
+
+ $question = new ConfirmationQuestion("Press [ENTER] to continue or [q] to quit ", true);
+ if (!$questionHelper->ask($this->input, $this->output, $question)) {
+ break;
+ }
+ $this->output->writeln("");
+ }
+ }
+ }
+
+
$this->output->writeln('');
- $this->output->writeln("You can install this package by typing:");
- $this->output->writeln(" " . $this->argv . " install " . $foundPackage->slug . "");
+
+ if ($installed && $updatable) {
+ $this->output->writeln("You can update this package by typing:");
+ $this->output->writeln(" " . $this->argv . " update " . $foundPackage->slug . "");
+ } else {
+ $this->output->writeln("You can install this package by typing:");
+ $this->output->writeln(" " . $this->argv . " install " . $foundPackage->slug . "");
+ }
+
$this->output->writeln('');
}