set -o errexit
# trap 'status=$?; printf '\''%b\n'\'' "Param is err.\n"; usage; exit $status' INT

usage() {
  printf '%s\n' "$(basename "$0"): [-d -l -s -h]" >&2
}

depth=1
list=1
summary=''
getopts=$(getopt -q -o "d:l:sh" -l "depth:,list:summary,help" -- "$@")
eval set -- "${getopts}"

while [ "$1" != '--' ]; do
  case "$1" in
    -d | --depth)
      depth="$2"
      shift
      ;;
    -l | --list)
      list="$2"
      shift
      ;;
    -s | --summary)
      summary='true'
      ;;
    -h | --help)
      usage
      exit 0
      ;;
    *) ;;
  esac
  shift
done

echo "depth = ${depth}"
echo "list = ${list}"
if [ -n "${summary}" ];then
  echo 'summary'
fi
