cornquest/justfile

52 lines
1.0 KiB
Plaintext

# 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 '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
# word count
words:
recsel -P text game.rec | wc -w