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

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

find_empty () {
	case ${1} in
		f )
			[ -z "${2}" ] && path="${PWD}" || path="${2}"
			find "${path}" -type f -empty | sort
		;;

		d )
			[ -z "${2}" ] && path="${PWD}" || path="${2}"
			find "${path}" -type d -empty | sort
		;;

		* )
			[ -d "${1}" ] && path="${1}" || path="${PWD}"
			find "${path}" -empty | sort
		;;
	esac
}

case ${1} in
	--help | -h)
		bashstyle-help -a "Christopher Roy Bratusek" -e "nano@jpberlin.de" -h "https://www.nanolx.org/"\
			-l "GNU GPL v3" -n "empty" -s "$(eval_gettext "find empty files")" -v "${BSNG_VERSION}" -y "${BSNG_YEAR}"\
			-o "$(eval_gettext "type:[f] [d]|(optional) find [f]iles or [d]irectories only")"\
			-o "$(eval_gettext "directory:|(optional) find empty files in directory (or current)")"
	;;

	* )
		find_empty "${1}" "${2}"
	;;
esac
