diff options
Diffstat (limited to 'nant-color')
-rwxr-xr-x | nant-color | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/nant-color b/nant-color new file mode 100755 index 0000000..ca5ea37 --- /dev/null +++ b/nant-color | |||
@@ -0,0 +1,52 @@ | |||
1 | #!/usr/bin/ruby | ||
2 | |||
3 | |||
4 | def main | ||
5 | IO.popen("nant #{ARGV.join(' ')}") { |pipe| | ||
6 | pipe.sync = true | ||
7 | while str = pipe.gets | ||
8 | str.sub!(/\n+/, '') | ||
9 | puts colorize(str) | ||
10 | end | ||
11 | } | ||
12 | end | ||
13 | |||
14 | def clear | ||
15 | return "\e[0m" | ||
16 | end | ||
17 | |||
18 | def red(str) | ||
19 | return "\e[31m" + str + clear | ||
20 | end | ||
21 | |||
22 | def green(str) | ||
23 | return "\e[32m" + str + clear | ||
24 | end | ||
25 | |||
26 | def yellow(str) | ||
27 | return "\e[33m" + str + clear | ||
28 | end | ||
29 | |||
30 | def black | ||
31 | return "\e[30m" | ||
32 | end | ||
33 | |||
34 | def hide | ||
35 | return "\e[8m" | ||
36 | end | ||
37 | |||
38 | def bright | ||
39 | return "\e[1m" | ||
40 | end | ||
41 | |||
42 | def colorize(str) | ||
43 | str.sub!(/(error \w+:.*)/, red('\1')) | ||
44 | str.sub!(/(warning \w+:.*)/, yellow('\1')) | ||
45 | |||
46 | str.sub!(/(Build Succeeded)/i, green('\1')) | ||
47 | str.sub!(/(Compilation succeeded)/, green('\1')) | ||
48 | str.sub!(/(\d+ warning\(s\))/, yellow('\1')) | ||
49 | return str | ||
50 | end | ||
51 | |||
52 | main() | ||