#!/bin/bash

ary=()

for i in *.ino ; do
  ary+=("$i")
done

for i in ${!ary[@]} ; do
  echo "$i : ${ary[$i]}"
done

echo -n "Input num for build&upload (q:quit) > "
read input

if [[ "$input" == "q" ]]; then
  exit
fi

if [ -n "${ary[$input]}" ]; then
  echo "$input : ${ary[$input]}"
  file=${ary[$input]}
  cp ${file} TestBuild/TestBuild.ino
  cd TestBuild
  ./compile.sh && ./upload.sh && ./monitor.sh
  cd .. 
else
  echo "Sorry, ${input} is not found."
fi



