Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added some helper functions to show colored messages

  • Loading branch information...
commit c158b5cb92a9c5417c94e5bc18c404110ef242ba 1 parent a37dc5d
@darlanalves darlanalves authored
View
18 Phakefile
@@ -1,8 +1,21 @@
<?php
+desc('Show some colors');
+task('colors', function() {
+ write(
+ 'Using colors:',
+ red('red star,'), "\n",
+ green('green leaf,'), "\n",
+ blue('blue sky,'), "\n",
+ yellow('yellow stone,'), "\n",
+ bold('"bolded text"'),
+ green("and a text with \nnew line!")
+ );
+});
+
desc('Dump all args');
task('args', function($app) {
echo "Arguments:\n";
- foreach ($app as $k => $v) echo "$k = $v\n";
+ foreach ($app as $k => $v) write(yellow($k), '=', green($v));
});
desc('Load the application environment');
@@ -29,7 +42,7 @@ group('test', function() {
// executing tasks
group('all', function() {
desc('Run absolutely every test everywhere!');
- task('run', 'test:units', function($application) {
+ task('run', 'test:units', 'colors', function($application) {
echo "All tests complete! ($application)\n";
});
});
@@ -55,4 +68,3 @@ group('test', function() {
});
task('default', 'test:all:run');
-?>
View
1  bin/phake
@@ -100,4 +100,3 @@ try {
} catch (Exception $e) {
phake\fatal($e);
}
-?>
View
6 lib/bash_colors.php
@@ -37,6 +37,8 @@ function write() {
foreach(func_get_args() as $part) {
$str[] = trim($part);
}
+ // just in case of a line with double quotes
$str = implode(' ', $str);
- echo `echo $str`;
-}
+ $line = trim(addcslashes($str, '"'));
+ echo `echo "$line"`;
+}
View
1  lib/builder.php
@@ -61,4 +61,3 @@ private function assign_description($thing) {
}
}
}
-?>
View
3  lib/global_helpers.php
@@ -31,4 +31,5 @@ function after($task, $lambda) {
function desc($description) {
builder()->desc($description);
}
-?>
+
+require_once 'bash_colors.php';
View
1  lib/option_parser.php
@@ -88,4 +88,3 @@ protected function next() {
return $this->args[$this->index++];
}
}
-?>
View
1  lib/phake.php
@@ -225,4 +225,3 @@ public function invoke($application) {
}
}
}
-?>
View
3  lib/utils.php
@@ -27,7 +27,7 @@ function fatal($exception, $message = null) {
echo "aborted!\n";
if (!$message) $message = $exception->getMessage();
if (!$message) $message = get_class($exception);
- echo $message . "\n\n";
+ write(red($message), "\n\n");
global $trace;
if ($trace) {
echo $exception->getTraceAsString() . "\n";
@@ -36,4 +36,3 @@ function fatal($exception, $message = null) {
}
die(1);
}
-?>
Please sign in to comment.
Something went wrong with that request. Please try again.