#!/bin/bash

# set -x

. .bashrc

function get_dev() {
     pip install -r requirements_dev.txt
     pip install -r requirements_test.txt
     if [ -d /home/vscode/core ]; then
        sudo chown -R vscode:  /home/vscode/core
    fi
}

echo "arguments are: "$1

case $1 in
    start)
        echo "Running container start"
        ./scripts/starts_ha.sh
    ;;
    dev-setup)
        get_dev
    ;;
    install)
        echo "Running container post installation"
        script/setup
    ;;
    translations)
        echo "Running container start"
        cd $HA
        python3 -m script.translations develop
    ;;
    hassfest)
        echo "Running container start"
        python3 -m script.hassfest
        # python -m script.hassfest --requirements --action validate --integration-path config/custom_components/versatile_thermostat/
    ;;
    restart)
        echo "Killing existing container"
        pkill hass
        echo "Restarting existing container"
        pwd
        ./scripts/starts_ha.sh
    ;;
esac
