Skip to content

Instantly share code, notes, and snippets.

@conradludgate
Created June 17, 2022 20:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conradludgate/5b2f639ba897c87ed59ba5edf621cde3 to your computer and use it in GitHub Desktop.
Save conradludgate/5b2f639ba897c87ed59ba5edf621cde3 to your computer and use it in GitHub Desktop.
Interactive cargo-vet
#!/bin/bash
inspect() {
local name="$1"
local from="$2"
local to="$3"
if [ "$from" = "0.0.0" ]
then
cargo vet inspect "$name" "$to"
else
cargo vet diff "$name" "$from" "$to"
fi
cargo vet certify "$name" "$to"
}
suggest_one() {
suggest=$(cargo vet --output-format json suggest)
suggestion=$(echo "$suggest" | jq ".suggest.suggest_by_criteria[\"$1\"][0]")
name=$(echo "$suggestion" | jq -r ".name")
from=$(echo "$suggestion" | jq -r ".suggested_diff.from")
to=$(echo "$suggestion" | jq -r ".suggested_diff.to")
read -p "Inspect $name $to? [Y]es/[N]o: " -n 1 process
case "$process" in
n|N)
return 1
;;
*)
inspect "$name" "$from" "$to"
;;
esac
}
while :
do
if ! suggest_one $1
then
exit 0
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment