#!/bin/bash
here=$(cd $(dirname $0); pwd)

command="$1"

if [ -z "${command}" ] || [ ${command} = "-h" ] || [ ${command} = "--help" ] || [ ${command} = "help" ]; then
    cat <<EOT >&2
usage: demodock [-h | --help | help] <subcommand> [<arg1>...]

Available subcommands are:
    up      Start a demodock server instance
    down    Stop a running demodock server instance
    build   Build a demo container
    shell   Drop into a shell for the last successfully built container (even intermediate ones)
    start   Start a demo container
    stop    Stop a demo container
    update  Update a running server with refreshed list of running demos
    ps      Examine running demo containers
    help    Show this help message
EOT
exit 1
fi

target="${here}/../libexec/demodock-${command}"
if [ ! -x "${target}" ]; then
    echo "'${command}' is not a demodock subcommand" >&2
    exit 1
fi

shift
exec ${here}/../libexec/demodock-${command} "$@"
