Skip to content

Instantly share code, notes, and snippets.

@kissarat
Created August 12, 2021 00:13
Show Gist options
  • Save kissarat/93fdf6bd5cbca385e87bc0851ede9240 to your computer and use it in GitHub Desktop.
Save kissarat/93fdf6bd5cbca385e87bc0851ede9240 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Report about lines of code in subdirectories
current=$(pwd)
target=$1
test -z $target && target=.
cd $target
target=$(pwd)
cd $current
report_dir=$2
test -z $report_dir && report_dir=$target/cloc-report
if [ ! -d "$report_dir" ]; then
mkdir -p "$report_dir"
echo "$report_dir"
fi
for name in `ls $target`; do
dir=$target/$name
if [ -d "$dir" ]; then
cloc "$dir" --json > $report_dir/$name.json
echo $name
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment