2020-11-02 09:21:19 -07:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
fail () {
|
|
|
|
echo "ERROR: $*" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1:$2 in
|
|
|
|
puzzle:)
|
2020-11-02 09:27:19 -07:00
|
|
|
read answer < answer.txt
|
|
|
|
cat <<EOT
|
2020-11-02 09:21:19 -07:00
|
|
|
{
|
2020-11-02 09:27:19 -07:00
|
|
|
"Answers": ["$answer"],
|
2021-02-24 16:34:35 -07:00
|
|
|
"Authors": ["neale"],
|
|
|
|
"Body": "I am a generated puzzle."
|
2020-11-02 09:21:19 -07:00
|
|
|
}
|
|
|
|
EOT
|
|
|
|
;;
|
|
|
|
file:moo.txt)
|
|
|
|
echo "Moo."
|
|
|
|
;;
|
|
|
|
file:*)
|
|
|
|
cat "$2" || exit 1
|
|
|
|
;;
|
|
|
|
answer:moo)
|
|
|
|
echo '{"Correct":true}'
|
|
|
|
;;
|
|
|
|
answer:error)
|
|
|
|
fail "you requested an error"
|
|
|
|
;;
|
|
|
|
answer:*)
|
|
|
|
echo '{"Correct":false}'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
fail "What is $1"
|
|
|
|
;;
|
|
|
|
esac
|