#!/bin/bash

# Get the absolute path of the repo root
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

# Run the CLI from its location while working from the repo root
cd "$REPO_ROOT"

log_file=$(mktemp)
npm install --prefix app/planqtn_cli 2>&1 > $log_file
if [ $? -ne 0 ]; then
  cat $log_file
  exit 1
fi

npm run dev --prefix app/planqtn_cli -- "$@"
state=$?

exit $state