Bump sequencer revision to 9

New API function echoinfo

New option -s to execute only one step

Step argruments are also passed to step info function
This commit is contained in:
2019-12-23 23:13:11 +01:00
parent f90e95461e
commit ef572f9d7e

View File

@@ -2,11 +2,12 @@
## Sequencer script is doing nothing on its own. It is included by a squence script
## which uses the sequencer.sh to provide sequencial operations with or without
## user interaction (see seqTemplate.sh)
## user interaction (see generated template which can be generated by calling this
## script directly)
## Version information
VERSION_REV=8
VERSION_REV=9
VERSION_MAJOR=0
VERSION_MINOR=0
@@ -15,6 +16,7 @@ VERSION_MINOR=0
QUIET=0
DRY=0
VERBOSE=0
SINGLE=0
ERNO=0
STEP_ARGS=
MAX_STEP=512
@@ -34,6 +36,8 @@ helpSequencer() {
echo " (e.g. exe,addconf,echerr,...)"
echo " --quiet, -q : Don't ask for permission to execute steps"
echo " If called without starting step number, only this help is shown"
echo " --single, -s : Execute only one step"
echo " If more than one step is requested, only the first will be executed"
echo " --verbose, -v : Verbose output (use exe() function to call shell commands in seqs)"
echo " ( e.g.: exe apt update )"
echo " --version : Display version of sequencer and revision of sequence"
@@ -42,11 +46,10 @@ helpSequencer() {
echo " No STEP or ALIAS : assume 1 as starting point"
echo " Single STEP or ALIAS : starting point of sequential process"
echo " Multiple STEPS or ALIAS : execute only given steps"
echo " execute only one step with using special step 0"
echo " ( e.g. only execute step 4: $0 \"4 0\" )"
echo " (e.g. $0 \"2 4 12\")"
echo " multiple steps need to be given as string"
echo " [STEP ARGUMENTS]"
echo " * : Arguments will be passed to selected steps as:"
echo " * : Arguments will be passed to selected steps and step infos as:"
echo " \$2 ..."
echo " \$1 is always the step number"
}
@@ -88,10 +91,10 @@ helpApi() {
echo " -f : <SOURCE> is a file"
echo " <SOURCE>"
echo " Text or file (-f) to create or added to <DESTINATION FILE>"
echo " <CONFIGFILE>"
echo " <DESTINATION FILE>"
echo " Target file to be created or modified."
echo
echo " step <Step number or alias>"
echo " step <STEP NUMBER OR ALIAS>"
echo " Executes a single step also by alias. Useful if step numbers get reorganized."
echo " dry-run is not applied in this function! The executed step is responsible."
echo
@@ -99,6 +102,10 @@ helpApi() {
echo " echo to stderr"
echo " [...] : all parameter are forwarded to echo"
echo
echo " echoinfo [...]"
echo " echo additional correctly indented line to step info"
echo " [...] : all parrameter are forwared to echo"
echo
echo " endCheckEmpty <VARIABLENAME> [DESCRIPTION]"
echo " exit 666 if variable is empty"
echo " <VARIABLENAME> : Name used within eval"
@@ -125,6 +132,11 @@ helpApi() {
# Echo to stderr
echoerr() { >&2 echo "$@"; }
# Echo additional line to info correctly indented
HELPINDENT=' : '
HELPINDENTAPPEND=' '
echoinfo() { printf '%s' "$HELPINDENTAPPEND"; echo "$@"; }
# endCheckEmpty <VariableName> [DESCRIPTION]
# DESCRIPTION : Optional text for error
endCheckEmpty() {
@@ -367,7 +379,7 @@ execute() {
echo -en "\n [STEP $1] "
existsFunction step_${1}_info
if [ $? -eq 0 ] ; then
step_${1}_info $1
step_${1}_info $1 "${STEP_ARGS[@]}"
else
# Add newline if no info is given
echo
@@ -468,9 +480,9 @@ continous() {
done
}
# selection <Step Number List (separated by space)>
# selection <STEP ARRAY>
# execute given step list
# e.g.: selection -q 1 4 12
# e.g.: selection -q (1, 4, 12)
selection() {
local step=0
local array=("$@")
@@ -598,7 +610,7 @@ displayHelp() {
if [ $? -eq 0 ] ; then
step_${i}_alias
echo " = $ALIAS"
printf ' : '
printf '%s' "$HELPINDENT"
else
echo -n " : "
fi
@@ -676,6 +688,10 @@ main() {
QUIET=1
shift
;;
--single|-s) # execute only one step and stop
SINGLE=1
shift
;;
--verbose|-v) # set verbose flag
VERBOSE=1
shift
@@ -715,20 +731,17 @@ main() {
echoerr -e " [W] No sequence revision found. Trying anyway...\n";
fi
# check for starting step
if [ $EMPTYCALL -ne 0 ] ; then
# End here on quiet mode and no step was given
if [ $QUIET -eq 1 ] ; then
if [ $EMPTYCALL -ne 0 ] && [ $QUIET -eq 1 ] ; then
exit 1;
fi
fi
if [ $DRY -ne 0 ] && [ $QUIET -eq 0 ] ; then
echo
echo " [W] Dry run active."
echo " Printed commands may not be accurate (e.g. quotation incorrect)"
echo " Sequence may ignore dry run"
read -p "Press enter to continue or Ctrl + c to abort"
echo " - Printed commands may not be accurate (e.g. quotation incorrect)"
echo " - Sequence may ignore dry run"
read -p "Press enter to continue or Ctrl + C to abort"
fi
parseAlias
@@ -741,7 +754,9 @@ main() {
fi
# check if more than one step is given and select execution mode
if [ "${#START[@]}" -gt "1" ]; then
if [ $SINGLE -ne 0 ] ; then
selection "${START[0]}"
elif [ "${#START[@]}" -gt "1" ]; then
selection "${START[@]}"
else
continous $START