Skip to content

Commit 00a2103

Browse files
Antreesybackportbot[bot]
authored andcommitted
feat(occ): show current version with occ app:update command
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent a6e435d commit 00a2103

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

core/Command/App/Update.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ protected function configure(): void {
4848
InputOption::VALUE_NONE,
4949
'show update(s) without updating'
5050
)
51+
->addOption(
52+
'showcurrent',
53+
null,
54+
InputOption::VALUE_NONE,
55+
'show currently installed version'
56+
)
5157
->addOption(
5258
'allow-unstable',
5359
null,
@@ -60,6 +66,7 @@ protected function configure(): void {
6066
protected function execute(InputInterface $input, OutputInterface $output): int {
6167
$singleAppId = $input->getArgument('app-id');
6268
$updateFound = false;
69+
$showOnly = $input->getOption('showonly') || $input->getOption('showcurrent');
6370

6471
if ($singleAppId) {
6572
$apps = [$singleAppId];
@@ -69,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6976
$output->writeln($singleAppId . ' not installed');
7077
return 1;
7178
}
72-
} elseif ($input->getOption('all') || $input->getOption('showonly')) {
79+
} elseif ($input->getOption('all') || $showOnly) {
7380
$apps = $this->manager->getAllAppsInAppsFolders();
7481
} else {
7582
$output->writeln('<error>Please specify an app to update or "--all" to update all updatable apps"</error>');
@@ -81,9 +88,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8188
$newVersion = $this->installer->isUpdateAvailable($appId, $input->getOption('allow-unstable'));
8289
if ($newVersion) {
8390
$updateFound = true;
84-
$output->writeln($appId . ' new version available: ' . $newVersion);
91+
$message = $appId . ' new version available: ' . $newVersion;
92+
if ($input->getOption('showcurrent')) {
93+
$message .= ' (current version: ' . $this->manager->getAppVersion($appId) . ')';
94+
}
95+
$output->writeln($message);
8596

86-
if (!$input->getOption('showonly')) {
97+
if (!$showOnly) {
8798
try {
8899
$result = $this->installer->updateAppstoreApp($appId, $input->getOption('allow-unstable'));
89100
} catch (\Exception $e) {

0 commit comments

Comments
 (0)