Permalink
Browse files

Display better output message for update command

  • Loading branch information...
MattKetmo committed Jul 1, 2013
1 parent b3555f4 commit c808ae0b5467e6a0d3d91ba9ef75e492a4a4974a
Showing with 21 additions and 2 deletions.
  1. +21 −2 src/Cliph/Command/UpdateCommand.php
@@ -3,6 +3,8 @@
namespace Cliph\Command;
use Herrera\Phar\Update\Manager;
use Symfony\Component\Console\Input\InputOption;
use Herrera\Json\Exception\FileException;
use Herrera\Phar\Update\Manifest;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -17,12 +19,29 @@ protected function configure()
$this
->setName('update')
->setDescription('Updates cliph.phar to the latest version')
->addOption('major', null, InputOption::VALUE_NONE, 'Allow major version update')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$manager = new Manager(Manifest::loadFile(self::MANIFEST_FILE));
$manager->update($this->getApplication()->getVersion(), true);
$output->writeln('Looking for updates...');
try {
$manager = new Manager(Manifest::loadFile(self::MANIFEST_FILE));
} catch (FileException $e) {
$output->writeln('<error>Unable to search for updates</error>');
return 1;
}
$currentVersion = $this->getApplication()->getVersion();
$allowMajor = $input->getOption('major');
if ($manager->update($currentVersion, $allowMajor)) {
$output->writeln('<info>Updated to latest version</info>');
} else {
$output->writeln('<comment>Already up-to-date</comment>');
}
}
}

0 comments on commit c808ae0

Please sign in to comment.