#!/bin/sh
set -eu

usage() {
	cat <<-'EOF'
		Usage:
		  lc
		  lc -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 [:upper:] [:lower:]'.


		Examples:

		  Normalize to lower-case:

		    $ echo EuAndreh | lc
		    euandreh


		  Keep the text as-is:

		    $ echo andreh | lc
		    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 '[:upper:]' '[:lower:]'
