set -o errexit
declare -r NAME="$(basename "${0}")"
-#declare -r DIR_NAME="$(cd "$(dirname "${0}")"; echo $(pwd))"
+################################################################################
+#
+# Default value options
+#
+#################################################################################
+VERBOSE=0
+DEBUG=0
+
+################################################################################
+#
+# Functions
+#
+#################################################################################
+usage() {
+echo "
+=head1 NAME
+
+${NAME}
+
+=head1 SYNOPSIS
+
+Example shell script with embedded POD documentation
+
+ -v, --verbose Print verbose mode
+ -d, --debug Print debug messages
+ -h, --help Print this help (alternatives: --man, --help2man)
+
+=head1 DESCRIPTION
+
+Long description
+
+=head1 SEE ALSO
+
+http://blog.nbdom.net/
+
+=head1 LICENSE
+
+Copyright (C) 2022 Nicolas Boisselier
+
+This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+
+See <http://www.gnu.org/licenses/>.
+
+=head1 AUTHOR
+
+Nicolas Boisselier <nico@nbdom.net>
+"
+}
+
+#################################################################################
+#
+# Args
+#
+#################################################################################
+ARGS=""
+ALL=0
+UNIQ=0
+while [ $# -gt 0 ]; do
+
+ case "$1" in
+
+ --all) ALL=1 ;;
+ --uniq) UNIQ=1 ;;
+
+ -*help|-h) usage | pod2text --width 250; exit 0 ;;
+ --man) usage | pod2man | man -l -; exit 0 ;;
+ --help2man) usage | pod2man; exit 0 ;;
+
+ --verbose|-v) VERBOSE=$(($VERBOSE+1)) ;;
+
+ --debug|-d) DEBUG=$(($DEBUG+1)) ;;
+
+ *) ARGS="$ARGS "
+
+ esac
+ shift
+
+done
+
+#################################################################################
+#
+# Main
+#
+#################################################################################
cd "$(dirname "$0")"/..
-pcregrep ${@:-'-h'} -o1 '(?:[:>]p(?:def)?\(.([\w-]+))' $(git ls-files | grep '\.php$') | sort | uniq -c
+[ "$ALL" = 1 ] && ARGS="$ARGS $(git ls-files | grep '\.php$')"
+
+EXP='(?:[:>]p(?:def)?\(["'"'"']([\w-]+))'
+if [ "$UNIQ" = 1 ]; then
+ pcregrep -h -o1 "$EXP" $ARGS | sort | uniq -c
+else
+ pcregrep -n -H -o1 "$EXP" $ARGS
+fi