#!/usr/bin/env bash
set -euo pipefail

function shell_escape() {
  python2 -c 'import pipes, sys; print pipes.quote(" ".join(sys.argv[1:]))' "$@"
}

function remote_call() {
  local host cmd
  host="$1"
  shift
  cmd="$(shell_escape "builtin cd \$ZOOX_WORKSPACE_ROOT && $@")"
  readonly host cmd
  ssh -tqXYC "$host" bash -ic "$cmd"
}

remote_call main-ai "$@"
