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