forked from realXtend/taiga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nant-color
executable file
·57 lines (45 loc) · 1.08 KB
/
nant-color
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env ruby
def main
IO.popen("nant #{ARGV.join(' ')}") { |pipe|
pipe.sync = true
while str = pipe.gets
str.sub!(/\n+/, '')
puts colorize(str)
end
}
end
def clear
return "\e[0m"
end
def red(str)
return "\e[31m" + str + clear
end
def green(str)
return "\e[32m" + str + clear
end
def yellow(str)
return "\e[33m" + str + clear
end
def black
return "\e[30m"
end
def hide
return "\e[8m"
end
def bright
return "\e[1m"
end
def colorize(str)
str.sub!(/(error \w+:.*)/, red('\1'))
str.sub!(/(warning \w+:.*)/, yellow('\1'))
str.sub!(/(Build Succeeded)/i, green('\1'))
str.sub!(/(Compilation succeeded)/, green('\1'))
str.sub!(/(\d+ warning\(s\))/, yellow('\1'))
str.sub!(/(Build Failed)/i, red('\1'))
str.sub!(/(Tests run: \d+, Failures: 0, Not run: 0,.*)/, green('\1'))
str.sub!(/(Tests run: \d+, Failures: 0, Not run: [1-9].*)/, yellow('\1'))
str.sub!(/(Tests run: \d+, Failures: [1-9].*)/, red('\1'))
str.sub!(/(Test Case Failures:)/, red('\1'))
return str
end
main()