moth

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

moth / cmd / mothd / testdata / cat0 / 2
Neale Pickett  ·  2021-03-05

mkpuzzle

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