-
Notifications
You must be signed in to change notification settings - Fork 6
/
gaugectl
executable file
·65 lines (57 loc) · 1.15 KB
/
gaugectl
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
#!/bin/bash -eu
readonly REPORT_PATH="${PWD}/reports/html-report/index.html"
readonly LANGUAGE_PLACEHOLDER="__lang__"
readonly MANIFEST_NAME="manifest.json"
readonly MANIFEST_TEMPLATE=$(
cat <<-EOM
{
"Language": "${LANGUAGE_PLACEHOLDER}",
"Plugins": [
"html-report"
]
}
EOM
)
inject_manifest() {
local LANGUAGE=${1:-"java"}
local TARGET_LOCATION=${2:-$PWD}
echo "${MANIFEST_TEMPLATE//${LANGUAGE_PLACEHOLDER}/${LANGUAGE}}" >"${TARGET_LOCATION}/${MANIFEST_NAME}"
}
remove_manifest() {
local TARGET_LOCATION=${1:-$PWD}
rm "${TARGET_LOCATION}/${MANIFEST_NAME}"
}
gauge_run() {
local TARGET_LANG=${1:-"java"}
./gaugew run --env "${TARGET_LANG}"
}
open_report() {
if [ ! -f "$REPORT_PATH" ]; then
echo " >> Relatorio nao existe. execute ./gradlew relatorio"
echo " >>>> Caminho utilizado: ${REPORT_PATH}"
exit 1
fi
if [ "$(uname)" = "Darwin" ]; then
open "${REPORT_PATH}"
else
xdg-open "${REPORT_PATH}"
fi
}
case $1 in
inject-manifest)
inject_manifest "$2" "$3"
;;
remove-manifest)
remove_manifest "$2"
;;
run)
gauge_run "$2"
;;
open-report)
open_report
;;
*)
echo "Invalid option"
exit 1
;;
esac