#!/bin/sh
set -eu

usage() {
	cat <<-'EOF'
		Usage:
		  uc
		  uc -h
	EOF
}

help() {
	cat <<-'EOF'


		Options:
		  -h, --help    show this message


		Transforms text from STDIN from upper-case to lower-case.  It is
		the equivalent of running 'tr [:lower:] [:upper:]'.


		Examples:

		  Normalize to lower-case:

		    $ echo EuAndreh | uc
		    EUANDREH


		  Keep the text as-is:

		    $ echo ANDREH | uc
		    ANDREH
	EOF
}


for flag in "$@"; do
	case "$flag" in
		(--)
			break
			;;
		(--help)
			usage
			help
			exit
			;;
		(*)
			;;
	esac
done

while getopts 'h' flag; do
	case "$flag" in
		(h)
			usage
			help
			exit
			;;
		(*)
			usage >&2
			exit 2
			;;
	esac
done
shift $((OPTIND - 1))


tr '[:lower:]' '[:upper:]'
