#!/bin/sh

OS=$(uname -s)
PROJ_DIR="$(pwd)"
CHEATNT_DIR="$PROJ_DIR/.cheatnt"
SECRET_KEYWORD=$1
# Resolve the directory where this script lives so init_db.py is always found,
# regardless of the caller's working directory.
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

if [[ -e "$CHEATNT_DIR" ]]; then
	echo "already initialized"
else
	if [[ $OS == "Linux" ]]; then
		mkdir .cheatnt
		touch .cheatnt/tracked
		python3 "$SCRIPT_DIR/init_db.py" $CHEATNT_DIR $SECRET_KEYWORD
		echo "initialized"
	elif [[ $OS == "Darwin" ]]; then
		mkdir .cheatnt
		touch .cheatnt/tracked
		python3 "$SCRIPT_DIR/init_db.py" $CHEATNT_DIR $SECRET_KEYWORD
		echo "initialized"
	elif [[ $OS == "Windows" ]]; then
		echo die trash
	fi
fi
