Skip to content

Instantly share code, notes, and snippets.

@nicolasochem
Last active July 8, 2017 19:56
Show Gist options
  • Save nicolasochem/6a813b2cd1af3c7e9837d3b37d6c9b75 to your computer and use it in GitHub Desktop.
Save nicolasochem/6a813b2cd1af3c7e9837d3b37d6c9b75 to your computer and use it in GitHub Desktop.
#!/bin/bash
# assuming parity is cloned
cat parity/ethcore/src/lib.rs | grep "mod " | sed -e "s/mod //" | sed -e "s/pub //" | sed -e "s/#\[macro_use\] //" | sed -e "s/;//" | sort > ethcore_modules
# count modules and sort
cat ethcore_modules | while read line; do
cat ethcore_modules | while read line2; do
if [ -d parity/ethcore/src/$line ]; then
find parity/ethcore/src/${line}/*.rs -exec cat {} \;
else
cat parity/ethcore/src/${line}.rs
fi| if grep " *use ${line2}:" >/dev/null ; then
printf "*"
fi
done | wc -c | tr -d '\n'
printf " $line\n"
done | sort -n | cut -d' ' -f2 > ethcore_modules_sorted
printf ","
cat ethcore_modules_sorted | while read line; do
printf "${line},"
done
printf "\n"
cat ethcore_modules_sorted | while read line; do
printf "$line,"
cat ethcore_modules_sorted | while read line2; do
if [ -d parity/ethcore/src/$line ]; then
find parity/ethcore/src/${line}/*.rs -exec cat {} \;
else
cat parity/ethcore/src/${line}.rs
fi| if grep " *use ${line2}:" >/dev/null ; then
printf "*,"
else
printf ","
fi
done
printf "\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment