#!/bin/bash
set -e

platform='unknown'
arch=$(uname)
if [[ "$arch" == 'Linux' ]]; then
  platform='linux'
elif [[ "$arch" == 'Darwin' ]]; then
  platform='darwin'
fi

if [[ "$platform" == 'unknown' ]]; then
  printf "Sorry, your platform - %s - is not currently supported.\n" "$arch"
  exit 1
fi

printf "Downloading dotty for $arch...\n"
curl "https://dotty.cloud/static/dotty-$platform-amd64" -o /tmp/dotty

printf "Installting dotty...\n"
mv /tmp/dotty /usr/local/bin/dotty
chmod +x /usr/local/bin/dotty

printf "Installation successful.\n\nGet started by running 'dotty register' or 'dotty login'.\n\n"
