cyoa/justfile

47 lines
980 B
Plaintext
Raw Normal View History

2022-09-29 22:25:51 +00:00
# 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?
2022-09-29 22:25:51 +00:00
_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/> [^{]* {{{{/> {{{{/' \
2022-09-29 22:25:51 +00:00
| 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