Add new option -d: extra debug infos

This commit is contained in:
benn 2025-05-28 12:23:08 +02:00
parent e89dde4180
commit 99ef9d3111

View file

@ -38,6 +38,8 @@ Usage: $this_script [OPTIONS] params
defaults can be used.
Options:
-d [--debug]
Add extra debugging infos
-h [--help]
print this help
-m [--main] <name_of_file_containing_main>
@ -59,41 +61,48 @@ EOF
main()
{
OPT_ALL="$(getopt -o hm:p:r: -l help,main:,project:,repo: --name "$0" -- "$@")"
#OPT_DEBUG=False # By default, debugging is off
OPT_ALL="$(getopt -o dhm:p:r: -l debug,help,main:,project:,repo: --name "$0" -- "$@")"
eval set -- "$OPT_ALL"
while true ; do
case $1 in
-h | --help) # Call help
-d | --debug)
OPT_DEBUG=True
shift
;;
-h | --help) # Call help
help
exit 0
;;
-m | --main)
OPT_MAIN=$2
shift 2
;;
-p | --project)
OPT_PROJECT=$2
shift 2
;;
-r | --repo )
OPT_REPO=$2
shift 2
-m | --main)
OPT_MAIN=$2
;;
--)
shift
break
;;
*)
echo "Invalid argument" >&2
exit 1
-p | --project)
OPT_PROJECT=$2
#shift 2
;;
-r | --repo )
OPT_REPO=$2
#shift 2
;;
--)
shift
break
;;
*)
echo "Invalid argument" >&2
exit 1
;;
esac
done
if [[ $OPT_DEBUG == "True" ]]; then
trap 'echo "At line $LINENO: $BASH_COMMAND"' DEBUG
fi
if ! command -v "${USE_PROGRAMME}" > /dev/null; then
echo "ERROR: cannot find " $USE_PROGRAMME
echo " You must install "$USE_PROGRAMME
@ -139,6 +148,17 @@ main()
cd $pwd
$(git clone $REPO .)
if [ ! -d $pwd/nbproject ]; then
echo "ERROR: Not a NetBeans project"
echo " Can't find: "$pwd"/nbproject"
exit 1
fi
if [ ! -f $pwd/nbproject/project.xml ]; then
echo "ERROR: Missing ./nbproject/project.xml"
echo " Netbeans project without a configuration file!"
exit 1
fi
cd $pwd/nbproject
sed -i -e "s/\(<name>\).*\(<\/name>\)/<name>$PROJECT<\/name>/g" project.xml