Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 96 lines (81 sloc) 2.257 kb
#!/usr/bin/env php
<?php
require dirname(__FILE__) . '/lib/phake.php';
require dirname(__FILE__) . '/lib/utils.php';
require dirname(__FILE__) . '/lib/global_helpers.php';
require dirname(__FILE__) . '/lib/option_parser.php';
require dirname(__FILE__) . '/lib/builder.php';
phake\Builder::$global = new phake\Builder;
try {
//
// Defaults
$action = 'invoke';
$task_names = array('default');
$trace = false;
$args = $GLOBALS['argv'];
array_shift($args);
$parser = new phake\OptionParser($args);
foreach ($parser->get_options() as $option => $value) {
switch ($option) {
case 't':
case 'trace':
$trace = true;
break;
case 'T':
case 'tasks':
$action = 'list';
break;
default:
throw new Exception("Unknown command line option '$option'");
}
}
$cli_args = array();
$cli_task_names = array();
foreach ($parser->get_non_options() as $option) {
if (strpos($option, '=') > 0) {
list($k, $v) = explode('=', $option);
$cli_args[$k] = $v;
} else {
$cli_task_names[] = $option;
}
}
if (count($cli_task_names)) {
$task_names = $cli_task_names;
}
//
// Locate runfile
$runfile = phake\resolve_runfile(getcwd());
$directory = dirname($runfile);
if (!@chdir($directory)) {
throw new Exception("Couldn't change to directory '$directory'");
} else {
echo "(in $directory)\n";
}
phake\load_runfile($runfile);
//
// Go, go, go
$application = phake\Builder::$global->get_application();
$application->set_args($cli_args);
$application->reset();
switch ($action) {
case 'list':
$task_list = $application->get_task_list();
if (count($task_list)) {
$max = max(array_map('strlen', array_keys($task_list)));
foreach ($task_list as $name => $desc) {
echo str_pad($name, $max + 4) . $desc . "\n";
}
}
break;
case 'invoke':
foreach ($task_names as $task_name) {
$application->invoke($task_name);
}
break;
}
} catch (phake\TaskNotFoundException $tnfe) {
phake\fatal($tnfe, "Don't know how to build task '$task_name'\n");
} catch (Exception $e) {
phake\fatal($e);
}
?>
Jump to Line
Something went wrong with that request. Please try again.