Argument parsing in bash

#!/bin/bash

ARG3=NO

for i in "$@"
do
case $i in
    -arg1=*|--argument1=*)
    ARG1="${i#*=}"
    shift # go to next arg=val
    ;;
    -arg2=*|--argument2=*)
    ARG2="${i#*=}"
    shift # go to next arg=val
    ;;
    --arg3)
    ARG3=YES
    shift # skip argument without value
    ;;
    *)
            # unknown option
    ;;
esac
done

if [ -z "$ARG1" ]; then
  echo "ARG1 can not be empty"
  exit 1
else
  if ! [[ $ARG1 =~ ^-?[0-9]+$ ]]; then
    echo "ARG1 must be a number"
    exit 1
  fi
fi

echo "ARG1  = ${ARG1}"
echo "ARG2  = ${ARG2}"
echo "ARG3  = ${ARG3}"