fixes #2
Introduce versioning to sequencer and seqs Refactored sequencer option handling More robust way to include sequencer.sh to seqs
This commit is contained in:
@@ -4,25 +4,34 @@
|
||||
## which uses the sequencer.sh to provide sequencial operations with or without
|
||||
## user interaction (see seqTemplate.sh)
|
||||
|
||||
## Version information
|
||||
|
||||
VERSION_REV=1
|
||||
VERSION_MAJOR=0
|
||||
VERSION_MINOR=0
|
||||
|
||||
## Start of generic script part
|
||||
|
||||
QUIET=0
|
||||
ERNO=0
|
||||
MAX_STEP=255
|
||||
TEMPLATE_NAME=seqTemplateExample.sh
|
||||
VERSION_STRING="${VERSION_REV}.${VERSION_MAJOR}.${VERSION_MINOR}"
|
||||
|
||||
function helpSequencer() {
|
||||
echo "Usage: ${0##*/} [Options] [Step Number(s)]"
|
||||
echo
|
||||
echo " [Options]"
|
||||
echo " -q : Don't ask for permission to execute next step"
|
||||
echo " If called without starting step number only this help is shown"
|
||||
echo " [Options]"
|
||||
echo " --help, -h : Display help"
|
||||
echo " --quiet, -q : Don't ask for permission to execute steps"
|
||||
echo " If called without starting step number, only this help is shown"
|
||||
echo " --version,-v : Display version of sequencer and revision of sequence"
|
||||
echo
|
||||
echo " [Step Number(s) 1-${MAX_STEP}]"
|
||||
echo " Single step number : starting point of process"
|
||||
echo " Multiple step numbers : 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 " [Step Number(s) 1-${MAX_STEP}]"
|
||||
echo " Single step number : starting point of process"
|
||||
echo " Multiple step numbers : execute only given steps"
|
||||
echo " execute only one step with using special step 0"
|
||||
echo " ( e.g. only execute step 4: $0 4 0 )"
|
||||
}
|
||||
|
||||
# endCheckEmpty [VariableName] [DESCRIPTION]
|
||||
@@ -217,24 +226,62 @@ function displayHelp() {
|
||||
fi
|
||||
}
|
||||
|
||||
# showVersion
|
||||
function showVersion() {
|
||||
echo "Sequencer ${VERSION_STRING}"
|
||||
echo -n "Seq Revision "
|
||||
if [ ! -z "${VERSION_SEQREV}" ] ; then
|
||||
echo "${VERSION_SEQREV}"
|
||||
else
|
||||
echo "-"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
# detect if option quiet is available
|
||||
if [ ! -z "$1" ] && [ $1 == "-q" ] ; then
|
||||
QUIET=1
|
||||
shift
|
||||
local START=0
|
||||
|
||||
# option check
|
||||
case "$1" in
|
||||
--help|-h) # show only help
|
||||
displayHelp
|
||||
exit 0;
|
||||
;;
|
||||
--quiet|-q) # detect if option quiet is available
|
||||
QUIET=1
|
||||
shift
|
||||
;;
|
||||
--version|-v) # version request
|
||||
showVersion
|
||||
exit 0;
|
||||
;;
|
||||
"") # Empty -> show help
|
||||
displayHelp
|
||||
# Assume starting at one for interactive mode
|
||||
START=1
|
||||
;;
|
||||
esac
|
||||
|
||||
# compatibility check of sequence
|
||||
if [ ! -z $VERSION_SEQREV ] && [ $VERSION_SEQREV -gt $VERSION_REV ] ; then
|
||||
echo "[ERROR] Unsupported sequence revision"
|
||||
showVersion
|
||||
exit 1
|
||||
fi
|
||||
# TODO exclude older versions if needed
|
||||
if [ -z $VERSION_SEQREV ] ; then
|
||||
echo -e "[WARNING] No sequence revision found. Trying anyway...\n";
|
||||
fi
|
||||
|
||||
# display help
|
||||
if [ -z "$1" ] ; then
|
||||
displayHelp
|
||||
START=1
|
||||
# check for starting step
|
||||
if [ ! -z "$1" ] ; then
|
||||
START=$1
|
||||
else
|
||||
# End here on quiet mode and no step was given
|
||||
if [ $QUIET -eq 1 ] ; then
|
||||
exit 1;
|
||||
fi
|
||||
else
|
||||
START=$1
|
||||
fi
|
||||
|
||||
|
||||
# check if more than one step is given and select execution mode
|
||||
if [ ! -z $2 ] ; then
|
||||
selection $@
|
||||
|
Reference in New Issue
Block a user