#!/bin/bash
server="$1"
shift

if ! [[ -e ./vars ]] ; then
	echo 'Please create a "vars" file using "vars.example" as a template'
	exit 1
fi
source ./vars

cmd="$1"
shift

code_clear=''
code_send='
'

case "$cmd" in
	stop) tmux send-keys -t "$TMUX_SESSION" -l "$code_clear" 'stop' "$code_send" ;;
	command) tmux send-keys -t "$TMUX_SESSION" -l "$code_clear" "$*" "$code_send" ;;
	*) tmux new-window -t $TMUX_SESSION: "./start.sh" || tmux new-session -s $TMUX_SESSION "./start.sh";;
esac
