Skip to content

Commit

Permalink
Display better output message for update command
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo committed Jul 1, 2013
1 parent b3555f4 commit c808ae0
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/Cliph/Command/UpdateCommand.php
Expand Up @@ -3,6 +3,8 @@
namespace Cliph\Command; namespace Cliph\Command;


use Herrera\Phar\Update\Manager; use Herrera\Phar\Update\Manager;
use Symfony\Component\Console\Input\InputOption;
use Herrera\Json\Exception\FileException;
use Herrera\Phar\Update\Manifest; use Herrera\Phar\Update\Manifest;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -17,12 +19,29 @@ protected function configure()
$this $this
->setName('update') ->setName('update')
->setDescription('Updates cliph.phar to the latest version') ->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) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$manager = new Manager(Manifest::loadFile(self::MANIFEST_FILE)); $output->writeln('Looking for updates...');
$manager->update($this->getApplication()->getVersion(), true);
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.