Skip to content

Instantly share code, notes, and snippets.

@Licenser
Created April 18, 2019 10:32
Show Gist options
  • Save Licenser/85ca9f78db51925ce6242980c3a0b0f1 to your computer and use it in GitHub Desktop.
Save Licenser/85ca9f78db51925ce6242980c3a0b0f1 to your computer and use it in GitHub Desktop.
#!/bin/sh
# requires `remarshal` and `jq` to be installed
if [ -d "$1" ]
then
path="$1"
else
path="."
fi
for d in $(remarshal -i $path/Cargo.toml -of json | jq -r '.dependencies | keys []')
do
dep=$(echo $d | sed -e 's/-/_/g')
if ! rg "use $dep(::|;| )" $path -trust > /dev/null
then
if ! rg "extern crate $dep;" $path -trust > /dev/null
then
if ! rg "[^a-z]$dep::" $path -trust > /dev/null
then
echo "Not used: $d";
fi
fi
fi
done
@Licenser
Copy link
Author

Licenser commented Apr 18, 2019

requires remarshal and jq to be installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment