Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Return exit code from SHOW command #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Console/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class ShowCommand extends \Symfony\Component\Console\Command\Command
const NAME = 'show';
const OPTION_IGNORE_REQUIRED_VERSION = 'ignore-required-version';
const OPTION_EXACT_AS_TILDA = 'exact-as-tilda';
const EXIT_CODE_UP_TO_DATE = 0;
const EXIT_CODE_OUTDATED = 1;

/** @var ComposerAccessor */
private $composerAccessor;
Expand Down Expand Up @@ -73,10 +75,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$input->getOption(self::OPTION_IGNORE_REQUIRED_VERSION),
$input->getOption(self::OPTION_EXACT_AS_TILDA)
);
$versionStatus = self::EXIT_CODE_UP_TO_DATE;
foreach ($packages as $package) {
$currentVersion = $package->getCurrentVersion()->getPrettyString();
if (!$package->isLatest()) {
$currentVersion = sprintf('<error>%s</error>', $currentVersion);
$versionStatus = self::EXIT_CODE_OUTDATED;
}

$table->addRow([
Expand All @@ -87,6 +91,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$table->render();

return $versionStatus;
}

/**
Expand Down