#! /bin/bash

# RED='\033[0;31m'
LIGHT_RED='\033[1;31m'
LIGHT_GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;36m'
NC='\033[0m' # No Color

function message {
    echo
    echo =======================
    echo "$1"
    echo =======================
    echo
}

function removeImages() {
    for f in $1; do
        # If any exists, then remove them all and exit;
        if [ -e "$f" ]; then
            rm -v $1
        else
            echo -e "none exist"
        fi
        break;
    done
}

function runRemoveImages() {
    removeImages "/images/california1/*-small.jpg"
    removeImages "/images/california2/*-small.jpg"
}

function removeMarkdown() {
    removeImages "$HOME/ElvenImages/california?.md"
}

function runAll() {
    runRemoveImages
    removeMarkdown
}

while true; do
    message "Menu"
    echo -e "$LIGHT_GREEN a) Remove Images"
    echo -e "$LIGHT_GREEN b) Remove Markdown"
    echo -e "$LIGHT_GREEN c) Run All (Images and Markdown)"
    echo -e "$YELLOW x) Exit (e and q also work)"
    echo -e "\n$NC"
    read -p "Please make a selection: " eotuyx
    case $eotuyx in
        [Aa]* ) runRemoveImages; continue;;
        [Bb]* ) removeMarkdown; continue;;
        [Cc]* ) runAll; continue;;
        [EeXxQq]* ) break;;
        * )  -e "\n$NC" + "Please answer with c, r or x.";;
    esac
done
