Index: branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/trusting.sh
===================================================================
--- branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/trusting.sh	(revision 8859)
+++ branches/2015/dev_r5092_CNRS18_TRUST/NEMOGCM/TRUST/trusting.sh	(revision 8883)
@@ -2,35 +2,95 @@
 
 
+## Possibility to call from outside
 cd $( dirname $0 )
-
-##--------------------------------------------------------------------------------
-## Set flags & defaults
-##--------------------------------------------------------------------------------
-
 TRUST_MAIN_DIR=$PWD
-TRUST_FLAG_HELP='false'
-TRUST_FLAG_DEBUG='false'; TRUST_FLAG_DEV='false' ; TRUST_FLAG_PROD='false'
-
-# Revision number of the tool
+
+## Tool revision in use
 rev=$( svn info | awk '/Last Changed Rev/ {print $NF}' )
 
 
 ##--------------------------------------------------------------------------------
-## Get short or long arguments from command line
-##--------------------------------------------------------------------------------
-
-while getopts a:b:de:f:j:hm:n:r:t:pu:v:w: arg; do
-
-    case $arg in
-	a)  TRUST_IO_FORC_TAR=$OPTARG;; b)    TRUST_SVN_BRANCH=$OPTARG;;
-	d) TRUST_FLAG_DEBUG='true'   ;; e)  TRUST_TEST_MAILING=$OPTARG;;
-	f) TRUST_IO_FORC_PATH=$OPTARG;; j) TRUST_COMPILE_NPROC=$OPTARG;;
-	h)  TRUST_FLAG_HELP='true'   ;; m)     TRUST_MAIN_HPCC=$OPTARG;;
-	n)      TRUST_CFG_NEW=$OPTARG;; r)       TRUST_CFG_REF=$OPTARG;;
-	t)  TRUST_JOB_TIMEOUT=$OPTARG;; p)   TRUST_FLAG_PROD='true'   ;;
-	u)    TRUST_MAIN_USER=$OPTARG;; v)       TRUST_SVN_REV=$OPTARG;;
-	w)     TRUST_DIR_WORK=$OPTARG;;
-	:) echo 'Arg. needed for '$OPTARG && TRUST_FLAG_HELP='true'   ;;
-	*)  TRUST_FLAG_HELP='true'                                    ;;
+## Flags default
+##--------------------------------------------------------------------------------
+
+TRUST_FLAG_DEBUG='false'; TRUST_FLAG_DEV='false'
+TRUST_FLAG_HELP='false' ; TRUST_FLAG_PROD='false'
+
+
+##--------------------------------------------------------------------------------
+## Options from command line
+##--------------------------------------------------------------------------------
+
+while getopts ab:c:de:hj:lm:n:p:r:s:t:u:v:-: shortopt; do
+
+##  Attempt to maintain consistency with 'makenemo' available options
+##o makenemo: a d e h j k m n r s t u v
+##o trusting: | | | = = | = = = | | | |
+
+    case $shortopt in
+	## Mandatory (HPCC environment)
+	'm') TRUST_MAIN_HPCC=$OPTARG    ;;
+
+	## NEMO configuration
+	'n') TRUST_CFG_NEW=$OPTARG      ;; 'r') TRUST_CFG_REF=$OPTARG     ;;
+
+	## Compilation
+	'j') TRUST_COMPILE_NPROC=$OPTARG;;
+
+	## Flags
+	'h') TRUST_FLAG_HELP='true'     ;;
+
+	## Implement long options for specific not to reducing further short possibilites
+	## https://stackoverflow.com/questions/402377/using-getopts-in-bash-shell-script-to-get-long-and-short-command-line-options
+	'-')
+	    [ $OPTIND -ge 1 ] && optind=$( expr $OPTIND - 1 ) || optind=$OPTIND
+            longopt=${!optind}
+	    
+	    OPTION=${longopt/=[0-9A-Za-z_-]*/}; OPTARG=${longopt/[a-z-]*=/}
+
+            case $OPTION in
+		## Mandatory (installation environment)
+		'--setup'   ) TRUST_MAIN_SETUP=$OPTARG   ;;
+
+		##  Alt 'CONFIG' directory for standalone 'TRUST' to check several local branches
+		##+ (default to ./../CONFIG parent)
+		'--cfgdir'  ) TRUST_DIR_WORK=$OPTARG     ;;
+
+		## Local working copy
+		'--branch'  ) TRUST_SVN_BRANCH=$OPTARG   ;;
+		'--update'  ) TRUST_SVN_REV=$OPTARG      ;;
+
+		## Compilation & Computing
+		'--timeout' ) TRUST_JOB_TIMEOUT=$OPTARG  ;; 
+
+		## Inputs
+		'--forctar' ) 
+		    TRUST_IO_FORC_TAR=''
+
+		    ## Set but not empty
+		    if [ $OPTARG ]; then 
+			TRUST_IO_FORC_TAR=$OPTARG
+		    else
+			OPTARG='null'
+		    fi
+                                                         ;;
+		'--forcpath') TRUST_IO_FORC_PATH=$OPTARG ;;
+
+		## Mailing
+		'--email'   ) TRUST_TEST_MAILING=$OPTARG ;;
+
+		## Flags (no argument needed)
+		'--dev'     ) TRUST_FLAG_DEV='true'  ; OPTARG='null';;
+		'--prod'    ) TRUST_FLAG_PROD='true' ; OPTARG='null';;
+		'--debug'   ) TRUST_FLAG_DEBUG='true'; OPTARG='null';;
+
+		*           ) printf "\033[0;31m%s illegal long option %s\033[0m\n" \
+		    $0 $OPTION;;
+            esac
+
+	    OPTIND=1; shift             ;;
+
+	## Illegal option
+	'?')  TRUST_FLAG_HELP='true'    ;;
     esac
 
@@ -42,7 +102,8 @@
 ##--------------------------------------------------------------------------------
 
-if [[ ! -e cfg/${TRUST_MAIN_USER}.cfg || ! -e cfg/${TRUST_MAIN_HPCC}.cfg \
-      || ${TRUST_FLAG_HELP} == 'true'                                      ]]; then
-    cat ./inc/trusting_help.txt
+if [[ ! -e ./cfg/${TRUST_MAIN_SETUP}.cfg || ! -e ./cfg/${TRUST_MAIN_HPCC}.cfg ]]; then
+
+    printf "\nUsage: %s -m arch --setup cfg [OPTIONS]\n"        $0
+    printf "\nSee help for options description, %s -h|--help\n" $0
 
     ## Color this section to part with help
@@ -53,5 +114,8 @@
 	    \nAt least 1 cfg file (arch or user) is missing or misspelled: \
 	    '%s.cfg' or '%s.cfg'\n"                                        \
-	    ${TRUST_MAIN_USER} ${TRUST_MAIN_HPCC}
+	    ${TRUST_MAIN_SETUP} ${TRUST_MAIN_HPCC}
+    else
+	printf "\033[0m"
+	cat ./inc/help.txt
     fi
 
@@ -66,6 +130,6 @@
     [ ${TRUST_FLAG_DEBUG} == 'true' ] && set -vx
 
-    . ./inc/trusting.env
-    . ./inc/trusting_func.sh
+    . ./inc/env.sh
+    . ./inc/functions.sh
 
 fi
@@ -80,5 +144,8 @@
 
 echo
-if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi
+## Formatting for email (test not in interactive mode)
+[ ! -t 0 ] && echo '<pre style="font: 2px/1px monospace;">'
+cat ./inc/banner.txt
+[ ! -t 0 ] && echo '</pre>'
 echo
 echo '****************************************************************************************************'
@@ -91,5 +158,5 @@
 printf "\t§ Testing configuration\t\t%s on branch %s\n" \ ${TRUST_CFG_REF} ${TRUST_SVN_BRANCH}
 printf "\t§ (Super)Computer\t\t%s\n" 		          ${TRUST_MAIN_HPCC}
-printf "\t§ User installation\t\t%s\n\n" 	          ${TRUST_MAIN_USER}
+printf "\t§ User installation\t\t%s\n\n" 	          ${TRUST_MAIN_SETUP}
 echo
 if [ ${TRUST_TEST_BENCHMARK} ]; then
@@ -160,5 +227,5 @@
 job_state
 
-printf "Perfs?"
+printf "Perfs?\n"
 job_perfs
 
