forked from cosyverif/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolorize.lua
More file actions
executable file
·47 lines (44 loc) · 1.14 KB
/
colorize.lua
File metadata and controls
executable file
·47 lines (44 loc) · 1.14 KB
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
#! /usr/bin/env lua
local Arguments = require "argparse"
local Colors = require 'ansicolors'
local parser = Arguments () {
name = "colorize",
description = "Colorize luacov output depending on coverage level",
}
parser:option "--file" {
description = "luacov output file",
default = "luacov.report.out",
}
local arguments = parser:parse ()
local file = io.open (arguments.file)
local found_summary = false
while true do
local line = file:read "*line"
if not line then
break
elseif line:match "^Summary" then
found_summary = true
for _ = 1, 3 do
file:read "*line"
end
elseif found_summary then
local value = line:match "(%S+)%%"
local color = "%{reset}"
if value then
value = tonumber (value)
if value == 100 then
color = "%{bright green}"
elseif value < 100 and value >= 80 then
color = "%{green}"
elseif value < 80 and value >= 50 then
color = "%{yellow}"
elseif value < 50 and value >= 20 then
color = "%{red}"
else
color = "%{bright red}"
end
end
print (Colors (color .. line))
end
end
file:close ()