-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-badge.sh
executable file
·44 lines (38 loc) · 1003 Bytes
/
generate-badge.sh
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
#!/bin/bash
while getopts 'b:d:e:f:o:s:' opt; do
case "$opt" in
b)
Before="$OPTARG"
if [ "$Before" == '[]' ]; then Before="$(date +%F)"; else Before=$1; fi
;;
d)
Dir="$OPTARG"
;;
e)
Exclude="$OPTARG"
;;
f)
Filename="$OPTARG"
;;
o)
OutDir="$OPTARG"
;;
s)
Since="$OPTARG"
;;
:)
echo "Usage: $(basename "$0") [-b Before] [-d Dir] [-e Exclude] [-f Filename] [-o OutputDir] [-s Since]"
exit 1
;;
?)
echo "Usage: $(basename "$0") [-b Before] [-d Dir] [-e Exclude] [-f Filename] [-o OutputDir] [-s Since]"
exit 1
;;
esac
done
if [ "$Before" == '[]' ]; then Before="$(date +%F)"; fi
echo "$Dir ${Exclude[*]} $Since $Before"
mkdir -p "$OutDir"
Count=$(hoc -d "$Dir" ${Exclude:+"-e" "${Exclude[@]}"} -e "${Exclude[@]}" -s "$Since" -b "$Before" -f "int")
echo "Hits of code: $Count"
anybadge -l "Hits of Code" -v "$Count" -f "$OutDir/$Filename" -c royalblue