#!/bin/bash
#
# arrg
#
function dohelp {
  echo "-----------------"
  echo "arrg version 1.0 "
  echo "-----------------"
  echo "language can be spanish or english "
  echo "timezone can be central or pacific " 
  echo "example:     arrg -l spanish "
  echo "example:     arrg -t central"
  echo "example:     arrg -l english -t pacific "
  echo "example:     arrg -help "
}

if [ $# -eq 0 ]; then
  echo "-----------------"
  echo "arrg version 1.0 "
  echo "-----------------"
  echo " for usage examples type..." 
  echo "     arrg -help   OR  arrg -h "
fi

    while [ $# != 0 ]; do
        flag="$1"
        case "$flag" in
            -a) echo "You provided the -a flag, which takes no arguments"
                ;;
            -l) if [ $# -gt 1 ]; then
                    arg="$2"
                    shift
                else
                    echo "You did not provide an argument for the -l flag"
                    exit 1
                fi
                echo "You supplied an argument for the -l flag: $arg"
                case "$arg" in 
                  spanish) echo "perro"
                  ;;
                  english) echo "dog"
                  ;;
                  *) echo "unrecognized LANGUAGE"
                esac
                ;; 
# =============================

            -t) if [ $# -gt 1 ]; then
                    arg="$2"
                    shift
                else
                    echo "You did not provide an argument for the -t flag"
                    exit 1
                fi
                echo "You supplied an argument for the -t flag: $arg"
                case "$arg" in
                  central) echo "Chicago"
                  ;;
                  pacific) echo "Los Angeles"
                  ;;
                  *) echo "unrecognized Timezone"
                esac
                ;;
# =============================
             -help)
                dohelp 
                ;;
             -h)
                dohelp
                ;;
             *) echo "Unrecognized flag or argument: $flag"
                ;;
        esac
        shift
    done