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