-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-badge.sh
executable file
·48 lines (43 loc) · 1.06 KB
/
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
45
46
47
48
#!/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)
Excld="$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
if [ "$Excld" != '[]' ]; then
IFS=$'\n' read -rd '' -a array <<< "$Excld"
for word in "${array[@]}"; do
Exclude="${Exclude} -e $word"
done
fi
mkdir -p "$OutDir"
Count=$(hoc -d "$Dir" ${Exclude:+${Exclude[@]}} -s "$Since" -b "$Before" -f "int")
echo "Hits of code: $Count"
anybadge -l "Hits of Code" -v "$Count" -f "$OutDir/$Filename" -c royalblue