added command line parsing

This commit is contained in:
Gerhard Hoffmann 2022-06-06 18:21:34 +02:00
parent 22fbaded16
commit 7d9fc7cb23

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# set -x # set -x
source ./general_utils
source ./log_helpers source ./log_helpers
source ./git_helpers source ./git_helpers
@ -162,18 +163,53 @@ update() {
############################################################################### ###############################################################################
if [ $# -ne 1 ] ; then
echo "Usage: $0 filename"
exit 1
else
if [ -z $IFS ]; then if [ -z $IFS ]; then
IFS=$'\n' IFS=$'\n'
fi fi
if read_config "$1" ; then readonly PROGRAM=`basename $0`
readonly VERSION="0.8.0"
config_filename=""
while test $# -gt 0; do
case $1 in
--file | --fil | --fi | --f | -file | -fil | -fi | -f )
__conf_file=yes
;;
--help | -hel | --he | --h | '--?' | -help | -hel | -he | -h | '-?' )
usage_and_exit 0
;;
--version | --versio | --versi | --vers | --ver | --ve | --v | \
-version | -versio | -versi | -vers | -ver | -ve | -v )
version
;;
--dbg | --db | --d | -dbg | -db | -d )
set_dbg_level $DEBUG
;;
-*)
error "Unrecognized option: $1"
;;
*)
if [ "$__conf_file" = "yes" ]; then
config_filename="$1"
__conf_file=""
else
error "Unrecognized parameter string: $1"
fi
break
;;
esac
shift
done
if ! [ -z "$config_filename" ]; then
if read_config "$config_filename" ; then
# set -x # set -x
if clone_customer_repository $customer_repository_path ; then if clone_customer_repository $customer_repository_path ; then
update update
fi fi
fi fi
else
error "config-file missing"
fi fi