blob: 83ccb294f5ab7b102a07d8ef8e159a2c7cede892 (
plain)
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
58
59
60
61
62
63
64
65
|
#!/usr/bin/env bash
colour_output=0
test -t 1 && colour_output=1
function bold() {
if [[ $colour_output = 1 ]]; then
printf "\x1B[1;33m$*\x1B[0m\n"
else
printf "$*\n"
fi
}
function bold_err() {
if [[ $colour_output = 1 ]]; then
printf "\x1B[1;31m$*\x1B[0m\n"
else
printf "$*\n"
fi
}
function succinct_output() {
local in_err errprefix errloc errsuffix missing_string
in_err=0
missing_string="$(bold_err '???')"
errprefix="$missing_string"
errloc="$missing_string"
errsuffix="$missing_string"
function output_reset() {
if [[ $3 =~ due\ to\ .*previous\ error ||
$3 =~ ^Could\ not\ compile\ ]]; then
return
fi
echo "$1: $2: $(bold "$3")"
errprefix="$missing_string"
errloc="$missing_string"
errsuffix="$missing_string"
}
while IFS=$'\n' read line; do
if [[ $line =~ ^(error|warning|help|note) ]]; then
if [[ $in_err = 1 ]]; then
output_reset "$errprefix" "$errloc" "$errsuffix"
fi
in_err=1
errprefix="$(cut -d: -f1 <<<"$line")"
errsuffix="$(cut -d: -f2- <<<"$line" | cut -c 2-)"
elif [[ $in_err = 1 && $line =~ ^[\ \t]*--\> ]]; then
errloc="$(sed 's/^.*--> //' <<<"$line")"
elif [[ $in_err = 1 && $line = "" ]]; then
output_reset "$errprefix" "$errloc" "$errsuffix"
in_err=0
elif [[ $in_err = 0 &&
$line != "To learn more, run the command again with --verbose." ]]; then
echo "$line"
fi
done
if [[ $in_err = 1 ]]; then
output_reset "$errprefix" "$errloc" "$errsuffix"
fi
}
cargo build "$@" 2>&1 | succinct_output
|