PSR2 for PHPCI/Command - Issue #18

This commit is contained in:
Dan Cryer 2013-05-16 15:14:10 +01:00
parent e4d32b3ea1
commit 65f93555be
3 changed files with 18 additions and 21 deletions

View file

@ -36,4 +36,4 @@ class GenerateCommand extends Command
$gen->generateModels();
$gen->generateStores();
}
}
}

View file

@ -42,7 +42,9 @@ class InstallCommand extends Command
$ghId = $this->ask('(Optional) Github Application ID: ', true);
$ghSecret = $this->ask('(Optional) Github Application Secret: ', true);
$cmd = 'mysql -u' . $dbUser . (!empty($dbPass) ? ' -p' . $dbPass : '') . ' -h' . $dbHost . ' -e "CREATE DATABASE IF NOT EXISTS ' . $dbName . '"';
$cmd = 'mysql -u' . $dbUser . (!empty($dbPass) ? ' -p' . $dbPass : '') . ' -h' . $dbHost .
' -e "CREATE DATABASE IF NOT EXISTS ' . $dbName . '"';
shell_exec($cmd);
$str = "<?php
@ -59,9 +61,10 @@ b8\Database::setReadServers(array('{$dbHost}'));
\$registry->set('install_url', '{$ciUrl}');
";
if(!empty($ghId) && !empty($ghSecret))
{
$str .= PHP_EOL . "\$registry->set('github_app', array('id' => '{$ghId}', 'secret' => '{$ghSecret}'));" . PHP_EOL;
if (!empty($ghId) && !empty($ghSecret)) {
$str .= PHP_EOL .
"\$registry->set('github_app', array('id' => '{$ghId}', 'secret' => '{$ghSecret}'));" .
PHP_EOL;
}
@ -76,8 +79,7 @@ b8\Database::setReadServers(array('{$dbHost}'));
$adminPass = $this->ask('Enter your desired admin password: ');
$adminName = $this->ask('Enter your name: ');
try
{
try {
$user = new \PHPCI\Model\User();
$user->setEmail($adminEmail);
$user->setName($adminName);
@ -88,15 +90,13 @@ b8\Database::setReadServers(array('{$dbHost}'));
$store->save($user);
print 'User account created!' . PHP_EOL;
}
catch(\Exception $ex)
{
} catch (\Exception $ex) {
print 'There was a problem creating your account. :(' . PHP_EOL;
print $ex->getMessage();
}
}
function ask($question, $emptyOk = false)
protected function ask($question, $emptyOk = false)
{
print $question . ' ';
@ -107,11 +107,10 @@ b8\Database::setReadServers(array('{$dbHost}'));
$rtn = trim($rtn);
if(!$emptyOk && empty($rtn))
{
if (!$emptyOk && empty($rtn)) {
$rtn = $this->ask($question, $emptyOk);
}
return $rtn;
}
}
}

View file

@ -15,8 +15,8 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use b8\Store\Factory;
use PHPCI\Builder,
PHPCI\BuildFactory;
use PHPCI\Builder;
use PHPCI\BuildFactory;
/**
* Run console command - Runs any pending builds.
@ -40,14 +40,12 @@ class RunCommand extends Command
$store = Factory::getStore('Build');
$result = $store->getByStatus(0);
foreach($result['items'] as $build)
{
foreach ($result['items'] as $build) {
$build = BuildFactory::getBuild($build);
if ($input->getOption('verbose')) {
$builder = new Builder($build, array($this, 'logCallback'));
}
else {
} else {
$builder = new Builder($build);
}
@ -59,4 +57,4 @@ class RunCommand extends Command
{
$this->output->writeln($log);
}
}
}