From 99ef9d31119f9c4fad3534b22b2bfdbe80ec553d Mon Sep 17 00:00:00 2001 From: benn Date: Wed, 28 May 2025 12:23:08 +0200 Subject: [PATCH] Add new option -d: extra debug infos --- nb_create.sh | 64 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/nb_create.sh b/nb_create.sh index 57b8b29..4b7258c 100755 --- a/nb_create.sh +++ b/nb_create.sh @@ -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] @@ -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>\)/$PROJECT<\/name>/g" project.xml