Browse Source

-a ACTION

David Sniperovitch 8 years ago
parent
commit
5a20865f49
4 changed files with 58 additions and 1 deletions
  1. 27 1
      cocktail
  2. 1 0
      t/01_1c_1d_1p_pub_export
  3. 1 0
      t/02_1c_1d_1p_pub
  4. 29 0
      t/22_bad_action

+ 27 - 1
cocktail

@@ -9,6 +9,7 @@ RC_PANDOC_FILES=5
 RC_ARGS=6
 RC_ARGS_DOSSIER=7
 RC_ARGS_PROJET=8
+RC_ARGS_ACTION=9
 
 end_with_code() {
   local rc=$1
@@ -432,9 +433,14 @@ else
 fi
 
 OPTERR=1
-while getopts "b:d:g:p:hv" option;
+while getopts "a:b:d:g:p:hv" option;
 do
   case $option in
+    a)
+        # ATTENTION   ^^   =  passage en majuscules
+        ACTION="${OPTARG^^}"
+        verbose "getopts: -$option) ACTION=$ACTION"
+        ;;
     b)
         URL_BASE=$OPTARG
         verbose "getopts: -$option) URL_BASE=$URL_BASE"
@@ -466,6 +472,26 @@ done
 shift $(($OPTIND - 1))
 verbose "ARGS=$@"
 
+
+###############################################################################
+# GESTION DES ARGUMENTS DE LA LIGNE DE COMMANDE
+###############################################################################
+
+# ACTION : SHAKE est la valeur par défaut
+if test -z "$ACTION";
+then
+  ACTION="SHAKE"
+fi
+
+# ACTION : uniquement SHAKE ou UNLOCK
+if test "$ACTION" != "SHAKE" -a "$ACTION" != "UNLOCK";
+then
+  die "getopts: -a ne peut être que SHAKE ou UNLOCK" $RC_ARGS_ACTION
+fi
+verbose "ACTION=$ACTION"
+
+
+
 if test -z "$DOSSIER";
 then
   die "getopts: -d DOSSIER is mandatory" $RC_ARGS

+ 1 - 0
t/01_1c_1d_1p_pub_export

@@ -8,6 +8,7 @@ DOSSIER=MonDossier$$
 PROJET=Abro2$$
 
 OUTPUT=$(./cocktail -v \
+           -a SHAKE \
            -d "$DOSSIER" \
            -p "$PROJET" \
            -b "$URL_BASE" \

+ 1 - 0
t/02_1c_1d_1p_pub

@@ -8,6 +8,7 @@ DOSSIER=MonDossier$$
 PROJET=Abro2$$
 
 OUTPUT=$(./cocktail -v \
+           -a sHaKe \
            -d "$DOSSIER" \
            -p "$PROJET" \
            -b "$URL_BASE" \

+ 29 - 0
t/22_bad_action

@@ -0,0 +1,29 @@
+#!/bin/bash
+
+printf "$PRINTFPATTERN" $0 : "Lancement avec une mauvaise action"
+
+URL_BASE=https%3A%2F%2Fpad.exegetes.eu.org%2Fp%2Fg.DSXI1kGFT1gjor66%24Abro-REP-Tele2-Principal%2Fexport%2Ftxt
+URL_GARDE=https%3A%2F%2Fpad.exegetes.eu.org%2Fp%2Fg.DSXI1kGFT1gjor66%24Abro-REP-Tele2-Garde%2Fexport%2Ftxt
+DOSSIER=Dossier$$
+PROJET=UnMauvais!..Projet
+
+OUTPUT=$(./cocktail -v \
+           -a ACTIONERREUR \
+           -d "$DOSSIER" \
+           -p "$PROJET" \
+           -b "$URL_BASE" \
+           -g "$URL_GARDE" 2>&1 >/dev/null) 
+RC=$?
+echo -n "RC=$RC "
+if test "$RC" -ne "9";
+then
+  # Test raté
+  echo "[FAILED]"
+else
+  echo "[  OK  ]"
+  RC=0
+fi
+echo "$OUTPUT"
+
+exit "$RC"
+