moth/cmd/transpile/testdata/cat1/1/mkpuzzle

38 lines
584 B
Plaintext
Raw Normal View History

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"],
"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