You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cyoa/justfile

46 lines
980 B

# 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