Merge pull request #171 from tomzx/refactor/move-self-update-to-application

Move the self-update command configuration in the Application class.
This commit is contained in:
Anton Medvedev 2015-02-13 11:56:07 +03:00
commit d05dc4b9ff
2 changed files with 27 additions and 11 deletions

13
bin/dep
View File

@ -44,27 +44,20 @@ $options = getopt('f::', ['file::']);
$userSpecifiedFile = null;
if (isset($options['f'])) {
$userSpecifiedFile = $options['f'];
$userSpecifiedFile = $options['f'];
} else if (isset($options['file'])) {
$userSpecifiedFile = $options['file'];
$userSpecifiedFile = $options['file'];
}
if (empty($userSpecifiedFile)) {
$deployFile = getcwd() . '/deploy.php';
} else {
$deployFile = ($userSpecifiedFile[0] === '/' ? '' : getcwd() . '/') . $userSpecifiedFile;
$deployFile = ($userSpecifiedFile[0] === '/' ? '' : getcwd() . '/') . $userSpecifiedFile;
}
if (is_file($deployFile) && is_readable($deployFile)) {
require $deployFile;
}
// Self-update command
$selfUpdate = new \KevinGH\Amend\Command('self-update');
$selfUpdate->setDescription('Updates deployer.phar to the latest version');
$selfUpdate->setManifestUri('http://deployer.org/manifest.json');
$console->add($selfUpdate);
$console->getHelperSet()->set(new \KevinGH\Amend\Helper());
// Run Deployer
$deployer->run();

View File

@ -7,6 +7,8 @@
namespace Deployer\Console;
use KevinGH\Amend\Command;
use KevinGH\Amend\Helper;
use Symfony\Component\Console\Application as Console;
use Symfony\Component\Console\Input\InputOption;
@ -23,4 +25,25 @@ class Application extends Console
return $inputDefinition;
}
}
protected function getDefaultCommands()
{
$commands = parent::getDefaultCommands();
$commands[] = $this->selfUpdateCommand();
return $commands;
}
private function selfUpdateCommand()
{
$selfUpdate = new Command('self-update');
$selfUpdate->setDescription('Updates deployer.phar to the latest version');
$selfUpdate->setManifestUri('http://deployer.org/manifest.json');
return $selfUpdate;
}
protected function getDefaultHelperSet()
{
$helperSet = parent::getDefaultHelperSet();
$helperSet->set(new Helper());
return $helperSet;
}
}