/** * @param string $text Text to output * @param array $arguments Optional arguments to use for sprintf * @param integer $indention * @param integer $style one of the STYLE_* constants * @return void */ function outputLine($text = '', array $arguments = array(), $indention = 0, $style = STYLE_DEFAULT) { if ($arguments !== array()) { $text = vsprintf($text, $arguments); } if ($style !== STYLE_DEFAULT && hasColorSupport()) { $text = "[" . $style . "m" . $text . "[0m"; } if ($indention > 0) { $wrappedLines = explode(PHP_EOL, wordwrap($text, MAXIMUM_LINE_LENGTH, PHP_EOL, true)); echo implode(PHP_EOL . str_repeat(' ', $indention), $wrappedLines); } else { echo wordwrap($text, MAXIMUM_LINE_LENGTH, PHP_EOL, true); } echo PHP_EOL; }
// --------------------------- /* set include paths */ set_include_path(dirname(__FILE__) . '/../classes' . PATH_SEPARATOR . get_include_path()); require_once 'phing/Phing.php'; /** * Code from Symfony/Component/Console/Output/StreamOutput.php */ function hasColorSupport() { if (DIRECTORY_SEPARATOR == '\\') { return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'); } return function_exists('posix_isatty') && @posix_isatty(STDOUT); } // default logger if (!in_array('-logger', $argv) && hasColorSupport()) { array_splice($argv, 1, 0, array('-logger', 'phing.listener.AnsiColorLogger')); } try { /* Setup Phing environment */ Phing::startup(); // Set phing.home property to the value from environment // (this may be NULL, but that's not a big problem.) Phing::setProperty('phing.home', getenv('PHING_HOME')); // Grab and clean up the CLI arguments $args = isset($argv) ? $argv : $_SERVER['argv']; // $_SERVER['argv'] seems to not work (sometimes?) when argv is registered array_shift($args); // 1st arg is script name, so drop it // Invoke the commandline entry point Phing::fire($args);