Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 85 lines (75 sloc) 2.01 KB
#!/usr/bin/php
<?php
namespace Maiden;
$timeZone = @date_default_timezone_get();
if (!$timeZone) {
$timeZone = "UTC";
}
date_default_timezone_set($timeZone);
$path = realpath(dirname(__FILE__));
ini_set("include_path", ".:{$path}:{$path}/lib:{$path}/modules/Piton/lib:" . PEAR_INSTALL_DIR);
require "Piton/Application/AutoLoader.php";
\Piton\Application\AutoLoader::register("{$path}/modules/Piton/lib/");
\Piton\Application\AutoLoader::register("{$path}/lib/");
$maidenRunner = new MaidenRunner($logger = new \Piton\Log\DefaultLogger());
$options = array();
// Commandline options
$options = array(
"-b" => array(
"description" => "Show a bare list of targets",
"action" => function($args) use ($maidenRunner) {
$maidenRunner->listTargets();
return false;
},
),
"-l" => array(
"description" => "Show list of targets with descriptions",
"action" => function($args) use ($maidenRunner) {
$maidenRunner->listTargetDescriptions();
return false;
},
),
"-q" => array(
"description" => "Run target and supress output",
"action" => function($args) use ($maidenRunner, $logger) {
$logger->setLevel($logger::LEVEL_WARNING);
},
),
"-v" => array(
"description" => "Run target with verbose output",
"action" => function($args) use ($maidenRunner, $logger) {
$logger->setLevel($logger::LEVEL_DEBUG);
},
),
"-h" => array(
"description" => "Displays this usages",
"action" => function($args, $options) {
echo "\n\tMaiden a PHP build tool by Paul Serby\n\n";
foreach ($options as $option => $optionData) {
echo "\t$option\t{$optionData["description"]}\n";
}
echo "\n";
return false;
}
)
);
array_shift($argv);
if (count($argv) == 0) {
$argv[] = "-l";
}
$arguments = array();
foreach ($argv as $arg) {
if (!isset($target) && isset($options[$arg])) {
if ($options[$arg]["action"]($argv, $options) === false) {
exit;
}
} else {
if (isset($target)) {
$arguments[] = $arg;
} else {
$target = $arg;
}
}
}
// Run the chosen target
$maidenRunner->run($target, $arguments);