scripts/stats-examples
#!/bin/sh
# usage: stats packages stats.csv (default)
# usage: stats examples stats-ex.csv
if [ $# -gt 0 ]; then
modules="$1/*"
else
modules="examples/*"
fi
if [ $# -gt 1 ]; then
out="$2"
else
out=dev/stats-examples.csv
fi
echo "example,files,comments,sloc" > $out
for m in $modules; do
if [ -d "$m" ]; then
echo "$m"
echo "$m,$(cloc "$m"/src --csv | grep "TypeScript" | cut -d ',' -f1 -f4-5)" >> $out
fi
done
echo "---"
awk -F ',' '{ files+=$2; comments+=$3; sloc+=$4 } END { print "files:", files, "\tcode:", sloc, "\tcomments:", comments, "\ttotal:", sloc + comments }' $out