#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright Christopher Roy Bratušek			#
#							#
#########################################################

. gettext.sh
export TEXTDOMAIN="bashstyle-rc"

opt="${1}"
shift

lowercase () {
	if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
		echo "${@,,}"
	else	echo "${@}" | tr '[:upper:]' '[:lower:]'
	fi
}

case "${opt}" in
	-w | -W )
		lowercase "${@}" | sed -re "s/(^)(.)/\U\2/g;s/(-|_| )(.)/\U \2/g"
	;;

	-c | -C )
		lowercase "${@}" | sed -re "s/(^|-|_| )(.)/\U\2/g"
	;;

	"" | * )
		bashstyle-help -a "Christopher Roy Bratusek" -e "nano@jpberlin.de" -h "https://www.nanolx.org/"\
			-l "GNU GPL v3" -n "camelcase" -s $"camelcase transform string"\
			-v "${BSNG_VERSION}" -y "${BSNG_YEAR}"\
			-o $"-w:test_string-a b|uppercase string elements (Test String A B)"\
			-o $"-c:test_string-a b|camelcase string (TestStringAB)"
	;;
esac
