-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount.sh
35 lines (31 loc) · 1.47 KB
/
count.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
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Please provide at least one path."
exit 1
fi
total_count=0
for dir in "$@"; do
for file in $(find "$dir" -type f -name "*.go" ! -name "*_test.go"); do
count=$(grep -E 'func [A-Z]' "$file" | grep -vE 'func New' | wc -l)
total_count=$((total_count + count))
done
done
echo "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"85\" height=\"20\" role=\"img\" aria-label=\"$total_count functions\" class=\"mdl-js\">
<title>$total_count functions</title>
<linearGradient id=\"s\" x2=\"0\" y2=\"100%\">
<stop offset=\"0\" stop-color=\"#bbb\" stop-opacity=\".1\"/>
<stop offset=\"1\" stop-opacity=\".1\"/>
</linearGradient>
<clipPath id=\"r\">
<rect width=\"85\" height=\"20\" rx=\"3\" fill=\"#fff\"/>
</clipPath>
<g clip-path=\"url(#r)\">
<rect width=\"0\" height=\"20\" fill=\"#13708a\"/>
<rect x=\"0\" width=\"85\" height=\"20\" fill=\"#13708a\"/>
<rect width=\"85\" height=\"20\" fill=\"url(#s)\"/>
</g>
<g fill=\"#fff\" text-anchor=\"middle\" font-family=\"Verdana,Geneva,DejaVu Sans,sans-serif\" text-rendering=\"geometricPrecision\" font-size=\"110\">
<text aria-hidden=\"true\" x=\"425\" y=\"150\" fill=\"#010101\" fill-opacity=\".3\" transform=\"scale(.1)\" textLength=\"750\">$total_count functions</text>
<text x=\"425\" y=\"140\" transform=\"scale(.1)\" fill=\"#fff\" textLength=\"750\">$total_count functions</text>
</g>
</svg>" > public/count.svg