/** * Execute the command. * * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; $this->version = $this->getApplication()->getVersion(); $parser = new VersionParser(); /** * Check for ancilliary options */ if ($input->getOption('rollback')) { $this->rollback(); return; } if ($input->getOption('check')) { $this->printAvailableUpdates(); return; } /** * Update to any specified stability option */ if ($input->getOption('dev')) { $this->updateToDevelopmentBuild(); return; } if ($input->getOption('pre')) { $this->updateToPreReleaseBuild(); return; } if ($input->getOption('stable')) { $this->updateToStableBuild(); return; } if ($input->getOption('non-dev')) { $this->updateToMostRecentNonDevRemote(); return; } /** * If current build is stable, only update to more recent stable * versions if available. User may specify otherwise using options. */ if ($parser->isStable($this->version)) { $this->updateToStableBuild(); return; } /** * By default, update to most recent remote version regardless * of stability. */ $this->updateToMostRecentNonDevRemote(); }
protected function initialize(InputInterface $input, OutputInterface $output) { if ($input->getOption('check') && $input->getOption('rollback')) { throw new \InvalidArgumentException('The --check option is not compatible with --rollback'); } if ($input->getOption('rollback') && ($input->getOption('pre') || $input->getOption('stable'))) { throw new InvalidArgumentException('The --rollback option is not compatible with --pre or --stable'); } if ($input->getOption('pre') && $input->getOption('stable')) { throw new InvalidArgumentException('The --pre and --stable options are mutually exclusive'); } if (!$input->getOption('pre') && !$input->getOption('stable')) { $versionParser = new VersionParser(); $input->setOption('stable', $versionParser->isStable($this->getApplication()->getVersion())); $input->setOption('pre', !$input->getOption('stable')); } }
public function testIsStable() { $parser = new VersionParser(); $this->assertTrue($parser->isStable('1.0.0')); $this->assertFalse($parser->isStable('1.0.0b')); $this->assertFalse($parser->isStable('1.0.0-dev')); }