2020-09-04 15:29:06 -06:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
|
|
fail () {
|
|
|
|
echo "ERROR: $*" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1:$2:$3 in
|
|
|
|
inventory::)
|
2020-10-16 14:18:44 -06:00
|
|
|
cat <<EOT
|
|
|
|
{
|
|
|
|
"Puzzles": [1, 2, 3,
|
|
|
|
4, 5]
|
|
|
|
}
|
|
|
|
EOT
|
2020-09-04 15:29:06 -06:00
|
|
|
;;
|
|
|
|
puzzle:1:)
|
|
|
|
cat <<EOT
|
|
|
|
{
|
|
|
|
"Answers": ["answer1.0"],
|
2021-02-24 16:34:35 -07:00
|
|
|
"Authors": ["author1.0"],
|
|
|
|
"Body": "<h1>moo.</h1>"
|
2020-09-04 15:29:06 -06:00
|
|
|
}
|
|
|
|
EOT
|
2020-09-14 18:23:56 -06:00
|
|
|
;;
|
|
|
|
puzzle:*)
|
|
|
|
fail "No such puzzle: $2"
|
2020-09-04 15:29:06 -06:00
|
|
|
;;
|
|
|
|
file:1:moo.txt)
|
|
|
|
echo "Moo."
|
|
|
|
;;
|
|
|
|
file:*:*)
|
2020-11-02 14:40:43 -07:00
|
|
|
cat "$3" || exit 1
|
2020-09-04 15:29:06 -06:00
|
|
|
;;
|
|
|
|
answer:1:answer1.0)
|
2020-10-16 14:18:44 -06:00
|
|
|
echo -n '{"Correct":true}'
|
2020-09-04 15:29:06 -06:00
|
|
|
;;
|
|
|
|
answer:1:*)
|
2020-10-16 14:18:44 -06:00
|
|
|
echo '{"Correct":false}'
|
2020-09-04 15:29:06 -06:00
|
|
|
;;
|
|
|
|
answer:*:*)
|
|
|
|
fail "Fail answer"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
fail "What is $1" 1>&2
|
|
|
|
;;
|
|
|
|
esac
|