Sequencer - Refresh step info output for help and execution context

This commit is contained in:
2022-02-20 21:57:39 +01:00
parent bc706fb121
commit cddfeb43dd

View File

@@ -8,8 +8,8 @@
## Version information
VERSION_REV=15
VERSION_MAJOR=0
VERSION_MINOR=1
VERSION_MAJOR=1
VERSION_MINOR=0
## Start of generic script part
@@ -105,7 +105,7 @@ sequencer.sh API
The sequencer.sh build-in functions are available in all sequence functions:
- step_config
If optional step_config is defined in the sequence, it will be called once before any step.
If optional step_config is defined in the sequence, it will be called once before execution of steps.
- step_[1-${MAX_STEP}]_info
- step_[1-${MAX_STEP}]_alias
- step_[1-${MAX_STEP}]
@@ -125,6 +125,9 @@ sequencer.sh global variables:
\$CONTEXT_HELP
0 : normal sequence execution
1 : current run only displays help (-h|-ha)
\$CONTEXT_EXE
0 : step info() function in help context
1 : step info() function in execution context
\$SEQUENCER_ARGS
String of all given options
\$SEQ_CONFIG_HOME
@@ -232,6 +235,7 @@ echo -e "${GREEN} echoinfoArgs [...]${NC}"
cat <<USAGE_API
echo argument description after step number or alias.
This must be called first in the step info function.
Does not add a newline at the end.
[...] : no parameter are forwared to echo
USAGE_API
@@ -334,13 +338,14 @@ outColor() {
}
# Echo additional line to info correctly indented
INDENT_HELP=' : '
INDENTAPPEND_HELP=' '
INDENT_HELP=' : '
INDENT_EXE=' '
INDENTAPPEND_HELP=' '
echoinfo() {
if [ $CONTEXT_HELP -ne 0 ] ; then
printf '%s' "$INDENTAPPEND_HELP"; echo "$@"
else
echo -ne "${RESTORE_POS}"; echo "$@"
printf '%s' "$INDENT_EXE"; echo "$@"
fi
}
@@ -349,7 +354,7 @@ echoinfo() {
echoinfoArgs() {
echo -e "${RESTORE_POS}$@"
if [ $CONTEXT_EXE -ne 0 ]; then
echo -ne "${RESTORE_POS}"
printf '%s' "$INDENT_EXE"
else
printf '%s' "$INDENT_HELP"
fi
@@ -725,7 +730,17 @@ execute() {
fi
if [ $QUIET -ne 2 ] ; then
echo -en "\n [STEP $1] ${SAVE_POS_EXE}"
existsFunction step_${1}_alias
[ $? -eq 0 ] && step_${1}_alias || ALIAS=
printf "\n [%3d] " $1
if [ ! -z "$ALIAS" ]; then
echo -en "${ORANGE}$ALIAS${NC}${SAVE_POS_ALIAS}"
# Only add newline if step info() available
existsFunction step_${1}_info
[ $? -eq 0 ] && printf "\n%s" "$INDENT_EXE"
else
echo -en "${SAVE_POS_EXE}"
fi
existsFunction step_${1}_info
if [ $? -eq 0 ] ; then
CONTEXT_EXE=1
@@ -1023,7 +1038,7 @@ displayHelp() {
fi
exit 1;
else
echo -e "\n Step (= alias) documentation:"
echo -e "\n Step (= alias) [STEP ARGS] : documentation"
for ((i=$loopStart; i<=$loopEnd; i++)); do
# Display step reference in help if step function exists
@@ -1046,14 +1061,16 @@ displayHelp() {
existsFunction step_$((i+1))
[ $? -eq 0 ] && [ $i -ne $stepFound ] && echo
fi
printf ' Step %3s ' $i
printf ' %3s ' $i
# Display alias if exists
existsFunction step_${i}_alias
if [ $? -eq 0 ] ; then
step_${i}_alias
echo -e " = ${ORANGE}$ALIAS${NC}${SAVE_POS_ALIAS}"
printf '%s' "$INDENT_HELP"
echo -en " = ${ORANGE}$ALIAS${NC}${SAVE_POS_ALIAS}"
# Newline only if step info() exists
existsFunction step_${i}_info
[ $? -eq 0 ] && printf '\n%s' "$INDENT_HELP"
else
echo -en " : ${SAVE_POS}"
fi
@@ -1061,9 +1078,9 @@ displayHelp() {
# Display step help only if info function exists
existsFunction step_${i}_info
if [ $? -eq 0 ] ; then
step_${i}_info $i
step_${i}_info $i
else
echo " - step_${i}_info() missing"
echo
fi
outColor
done
@@ -1255,7 +1272,6 @@ main() {
fi
checkStep "${START[0]}"
if [ $? -ne 0 ] ; then
echoseq " [I] Configuring sequence (step_config)"
step_config "${STEP_ARGS[@]}"
if [ $? -ne 0 ]; then
echoerr " [E] Configuring sequence failed"