#!/bin/bash
set -e # fail on any error

echo -e "\nFully Rebuildan~\n"

# total clean
bash fullclean

# use setup script instead
bash setup

echo -e "\nErase flash? y/n"
read wipe
if [ "$wipe" == "y" ]; then
	bash erase-flash
fi

# echo -e "\nRun menuconfig y/n?\n"
# read menuconfig
# if [ "$menuconfig" == "y" ]; then
# 	bash menuconfig
# fi

echo -e "\nSave as Default Config? y/n?\n"
read defconfig
if [ "$defconfig" == "y" ]; then
	bash save-defconfig
fi

echo -e "\nBuild, Flash, and Monitor Now? y/n"
read flashmon
if [ "$flashmon" == "y" ]; then
	echo -e "\nBuild, Flashing, and Monitoran~\n"
	idf.py --preview flash
	echo -e "\nFlashed... Short Delay Before Monitor\n"
	sleep 1
	idf.py --preview monitor
else
	echo -e "\nBuild Now? y/n"
	read build
	if [ "$build" == "y" ]; then
		echo -e "\nBuildan~\n"
		idf.py --preview build
		echo -e "\nBuild complete\n"
	fi
fi

echo -e "\nAll done :3\n"