Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e3818e8e4a
Fetching contributors…

Cannot retrieve contributors at this time

executable file 95 lines (75 sloc) 2.389 kb
#!/usr/bin/env php
<?php
if (
(!@include __DIR__.'/../../autoload.php')
&& (!@include __DIR__.'/vendor/autoload.php')
) {
die('You must set up the project dependencies, run the following commands:'
."\n".
'curl -s http://getcomposer.org/installer | php'."\n".
'php composer.phar install'."\n");
}
use Phpsog\Command\BuildCommand;
use Phpsog\Command\HelpCommand;
use Phpsog\Command\InitCommand;
use Phpsog\Command\StatusCommand;
use Phpsog\Command\UnknownCommand;
use Phpsog\Command\VersionCommand;
use Phpsog\Factory;
// Convert internal errors to exceptions
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});
try {
$phpsogDirectory = __DIR__;
$projectDirectory = getcwd();
$argv = $_SERVER['argv'];
$newArgv = array();
// Here
foreach ($argv as $arg) {
switch (true) {
case (strpos($arg, '--phpsog-dir=') === 0):
$phpsogDirectory = substr($arg, strlen('--phpsog-dir='));
break;
case (strpos($arg, '--project-dir=') === 0):
$projectDirectory = substr($arg, strlen('--project-dir='));
break;
default:
$newArgv[] = $arg;
break;
}
}
$argv = $newArgv;
$f = new Factory();
$app = $f->createNewApplication($phpsogDirectory, $projectDirectory);
if (count($argv) === 1) {
array_push($argv, 'help');
}
$cmd = null;
switch (true) {
case ($argv[1] === 'version'):
case ($argv[1] === '--version'):
$cmd = new VersionCommand($argv);
break;
case ($argv[1] === 'help'):
case ($argv[1] === '--help'):
$cmd = new HelpCommand($argv);
break;
case ($argv[1] === 'init'):
$cmd = new InitCommand($argv);
break;
case ($argv[1] === 'build'):
$cmd = new BuildCommand($argv);
break;
case ($argv[1] === 'status'):
$cmd = new StatusCommand($argv);
break;
default:
$cmd = new UnknownCommand($argv);
break;
}
$app->executeCommand($cmd);
$app->getLogger()->flush();
} catch (Exception $e) {
die('Error: ' . $e->getMessage() . "\n");
}
Jump to Line
Something went wrong with that request. Please try again.