Skip to content

Instantly share code, notes, and snippets.

@vilmibm
Created October 30, 2014 21:34
Show Gist options
  • Save vilmibm/edf5e7aa3b31e9c7804f to your computer and use it in GitHub Desktop.
Save vilmibm/edf5e7aa3b31e9c7804f to your computer and use it in GitHub Desktop.
#!/bin/bash
POETRYHOME=/var/local/poetry
help () {
cat << EOM
usage: $0 [-t templatefile] [-d dbname] [-h]
t: pick a template file. if not an absolute path, uses $POETRYHOME/templates/\$t.json
default: $POETRYHOME/templates/haiku.json
d: pick a database
default: tildetowno
h: display this help and exit
examples:
poem -t sestina # generate a sestina from the standard tildetown corpus
poem -t /home/me/tmpl.json # generate a poem using your cool custom template and standard tildetown corpus
poem -t sonnet -d mycorpus # generate a sonnet using a non-standard database on data.tilde.town
EOM
}
DB=tildetown
TMPL=$POETRYHOME/templates/haiku.json
while getopts "ht:d:" opt; do
case $opt in
t)
if echo $OPTARG | grep "^/" > /dev/null; then
TMPL=$OPTARG
else
TMPL=$POETRYHOME/templates/$OPTARG.json
fi
;;
d)
DB=$OPTARG
;;
h)
help
exit 0
;;
\?)
help
exit 1
;;
esac
done
# TODO
# * read template file and scp it to data.tilde.town:/temp/<rand>.json
# * issue ssh to call wrapper script with provided tmpl/db args
# * echo result of remote command
# TODO this will happen on data.tilde.town:
source $POETRYHOME/venvs/prosaic/bin/activate
cd $POETRYHOME/src/prosaic/prosaic
# TODO this will become an ssh invocation
hy __init__.hy create $TMPL $DB data.tilde.town
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment