cornquest/justfile

118 lines
2.2 KiB
Plaintext
Raw Normal View History

2023-10-17 04:16:35 +00:00
db := 'db/game.rec'
2022-10-10 17:19:24 +00:00
# show all commands
default:
just --list --unsorted
# super plain boring output
_map:
2023-10-17 04:16:35 +00:00
recsel -t game {{db}} | recfmt '"{{{{name}}": "{{{{id}}", '
2022-10-10 17:19:24 +00:00
2023-10-23 15:14:55 +00:00
# build dot file (tmp file)
2022-10-10 17:19:24 +00:00
_dot:
2023-10-23 15:14:55 +00:00
make dot
2022-10-10 17:19:24 +00:00
2023-10-23 15:14:55 +00:00
# build data object (tmp file)
2022-10-10 17:19:24 +00:00
_data:
2023-10-23 15:14:55 +00:00
make data
# build a graph of all the nodes
graph:
make graph
2022-10-10 17:19:24 +00:00
# plain output
build: _data
2023-10-17 04:16:35 +00:00
mustache tmp/data {{db}} \
2022-10-10 17:19:24 +00:00
| recfmt '{{{{id}}: {{{{text}}|' \
| sed -e 's/|/\n\n/g' \
# read the story
browse:
just build | fmt | less
# remove generated files
clean:
2023-10-17 04:16:35 +00:00
rm -f tmp/* out/*
2022-10-10 17:19:24 +00:00
2023-10-17 13:23:32 +00:00
# word count and number of nodes
info:
echo "$(recinf -t game {{db}}) nodes" \
&& echo "$(recsel -t game -P text {{db}} | wc -w | awk '{ print $1}') words"
2023-10-17 04:16:35 +00:00
# rebulid graph on change
2023-10-23 03:59:09 +00:00
watch-graph:
2023-10-17 04:16:35 +00:00
ls {{db}} | entr -c just graph
2023-10-23 03:59:09 +00:00
# rebulid pdf on change
watch-pdf:
ls {{db}} | entr -c just pdf
2023-10-17 04:16:35 +00:00
# shuffle ids
_shuffle:
2023-10-23 15:14:55 +00:00
recsel -t game -P id -C db/game.rec \
2023-10-17 04:16:35 +00:00
| shuf --random-source=/dev/urandom \
| gsed -e '/^0$/d' -e '1 i 0'
2023-10-18 13:20:28 +00:00
# story in random order, starting with 0
2023-10-17 04:16:35 +00:00
randomize:
for n in $(just _shuffle); do recsel -t game -e "id='$n'" db/game.rec; echo; done
# renumber the randomized list
renumber:
#!/usr/bin/env zsh
tmpfile=$(mktemp)
echo "$tmpfile"
2023-10-23 03:59:09 +00:00
cp {{db}} {{db}}.bak
2023-10-17 04:16:35 +00:00
just randomize > "$tmpfile"
j=$(recinf -t game "$tmpfile")
recdel -t game -n 0-$((j - 1)) {{db}}
for i in {0..$((j - 1))}
do
name=$(recsel -n "$i" -P name "$tmpfile")
text=$(recsel -n "$i" -P text "$tmpfile")
2023-10-23 03:59:09 +00:00
#echo "$i $name $text"
2023-10-17 04:16:35 +00:00
recins -t game -f name -v "$name" -f text -v "$text" {{db}}
done
rm "$tmpfile"
2023-10-23 03:59:09 +00:00
# make ms
2023-10-23 15:14:55 +00:00
_ms:
make ms
2023-10-17 04:16:35 +00:00
# make pdf
2023-10-23 15:14:55 +00:00
pdf:
make pdf
2023-10-17 04:16:35 +00:00
# make ascii doc
2023-10-23 15:14:55 +00:00
ascii:
make ascii
2023-10-17 04:16:35 +00:00
# make twee
twee:
#!/usr/bin/env zsh
exec > out/story.twee
cat<<EOF
:: StoryTitle
CORNQUEST
:: StoryData
{
"start": "beginning",
"ifid": "BDB6BEED-D6E0-4F71-9227-A8AD27067935"
}
EOF
mustache tmp/data <(sed 's/{{{{\([^}]*\)}}/[[{{{{\1}}|\1]]/g' {{db}}) | recsel -t game | recfmt -f templates/twee.template
# make twine html
html: twee
tweego --format=harlowe-3 --output=out/story.html out/story.twee
# make twine json
json: twee
tweego --format=twison --output=out/json.html out/story.twee
2023-10-17 04:16:35 +00:00
# generate tags
tags:
2023-10-23 15:14:55 +00:00
make tags