# Opens multiple files in subdirectories with geany
# Created: 2014.11.23.13
# Author: Kārlis Kalviškis <eko@lanet.lv>
# License: GPLv3


# For translation
export TEXTDOMAIN="geany-all-files"
. gettext.sh


# Is there a file or directory?
if [ ! $1 ] ; then
	echo 
	echo `eval_gettext 'Opens multiple files in sub-directories with geany.'`
	echo 
	echo `eval_gettext 'Missing parameters. Usage:'`
	echo $0 `eval_gettext 'pattern'`
	echo
	echo `eval_gettext 'Pattern is as a filter for file selection'`:
	echo `eval_gettext 'pattern'` \'txt\' `eval_gettext '(without apostrophe) will open'`
	echo `eval_gettext 'all files with extensions like'` txt, TXT ... \;
	echo `eval_gettext 'pattern'` \'\\\(css\\\)\\\|\\\(htm.?\\\)\' `eval_gettext '(without apostrophe) will open'`
	echo `eval_gettext 'all files with extensions like'` css, CSS, htm, HTM, html ... .
	echo
	exit -1
fi

if [ $(command -v xargs) ]; then
	if [ $(command -v geany) ]; then
		find * -type f -print | grep -i -P "$1$" | xargs geany
	else
		echo `eval_gettext 'Error! Command missing:'` geany
		exit 1
	fi
else
	echo `eval_gettext 'Error! Command missing:'` xargs
	exit 1
fi



