add: tool to validate if declared opposites exist

pull/306/head
Théo BARRAGUÉ 2021-02-22 11:19:01 +01:00
parent c2149bee81
commit ebfcf6a169
No known key found for this signature in database
GPG Key ID: A5DE7A72475C3A68
1 changed files with 17 additions and 0 deletions

17
tools/validate_opposites.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
opposites=$(cat relationships/definition.json | grep '"opposite"' | cut -d ':' -f 2 | tr -d ' ' | tr -d '"')
for opposite in $opposites
do
cat relationships/definition.json | grep '"name": "'$opposite'"' >/dev/null 2>&1
res=$?
if [ "$res" -eq 1 ]
then
echo "'$opposite' not found"
exit 1
fi
done
echo "OK, all opposites seem to point to existing relationships"
exit 0