the regex for building the DOT text was too greedy! in cases where there were more than two branches in a given text, it would only match the first branch and the second branch. because of how greedy it was. so hopefully this should fix that. at least, graph.png looks correct to me now.
47 lines
980 B
Makefile
47 lines
980 B
Makefile
# show all commands
|
|
default:
|
|
just --list --unsorted
|
|
|
|
# super plain boring output
|
|
_map:
|
|
recsel game.rec | recfmt '"{{{{name}}": "{{{{id}}", '
|
|
|
|
# build dot file
|
|
# TODO: change id to name? or id /and/ name?
|
|
_dot:
|
|
#!/usr/bin/env zsh
|
|
echo "digraph {" > dot
|
|
recsel game.rec \
|
|
| recfmt '{{{{id}} -> {{{{text}}|' \
|
|
| sed -e 's/|/\n\n/g' \
|
|
| sed -e '/./{H;$!d;}' -e 'x; s/\n//g; G;' \
|
|
| sed -e 's/}}[^{]*{{{{/}} {{{{/g' -e 's/> [^{]* {{{{/> {{{{/' \
|
|
| sed -e '/{{{{/!d' -e 's/\.$//' \
|
|
| sed -e 's/> \(.*\)$/> { \1 };/' \
|
|
>> dot
|
|
echo "}" >> dot
|
|
|
|
# build a graph of all the nodes
|
|
graph: _data _dot
|
|
mustache data dot | dot -Tpng > graph.png
|
|
|
|
# build data object
|
|
_data:
|
|
echo "{" $(just _map) "}" \
|
|
| sed -e 's/, }/ }/' \
|
|
> data
|
|
|
|
# plain output
|
|
build: _data
|
|
mustache data game.rec \
|
|
| recfmt '{{{{id}}: {{{{text}}|' \
|
|
| sed -e 's/|/\n\n/g' \
|
|
|
|
# read the story
|
|
browse:
|
|
just build | fmt | less
|
|
|
|
# remove generated files
|
|
clean:
|
|
rm -f dot data graph.png
|