#!/bin/sh
# Vistara's attach CLI: `vistara attach [session]`, `vistara list`.
# Shipped in Vistara.app/Contents/Resources/host; Settings can link it into PATH, so follow the link back here.
self="$0"
while [ -L "$self" ]; do
  link="$(readlink "$self")"
  case "$link" in
    /*) self="$link" ;;
    *) self="$(dirname "$self")/$link" ;;
  esac
done
here="$(cd "$(dirname "$self")" && pwd -P)"
node="$here/../node/bin/node"
[ -x "$node" ] || node="$(command -v node)"
if [ -z "$node" ]; then
  echo "vistara: no Node to run on (expected $here/../node/bin/node)" >&2
  exit 1
fi
exec "$node" "$here/vistara-cli.js" "$@"
