moth

Monarch Of The Hill game server
git clone https://git.woozle.org/neale/moth.git

moth / cmd / transpile / testdata / cat1 / 1
Neale Pickett  ·  2021-02-25

mkpuzzle

 1#! /bin/sh
 2
 3fail () {
 4    echo "ERROR: $*" 1>&2
 5    exit 1
 6}
 7
 8case $1:$2 in
 9    puzzle:)
10        read answer < answer.txt
11        cat <<EOT
12{
13    "Answers": ["$answer"],
14    "Authors": ["neale"],
15    "Body": "I am a generated puzzle."
16}
17EOT
18        ;;
19    file:moo.txt)
20        echo "Moo."
21        ;;
22    file:*)
23        cat "$2" || exit 1
24        ;;
25    answer:moo)
26        echo '{"Correct":true}'
27        ;;
28    answer:error)
29        fail "you requested an error"
30        ;;
31    answer:*)
32        echo '{"Correct":false}'
33        ;;
34    *)
35        fail "What is $1"
36        ;;
37esac