diff --git a/sequencer/sequencer.sh b/sequencer/sequencer.sh index e4e7bbd..4d516a7 100755 --- a/sequencer/sequencer.sh +++ b/sequencer/sequencer.sh @@ -8,7 +8,7 @@ ## Version information VERSION_REV=12 -VERSION_MAJOR=0 +VERSION_MAJOR=1 VERSION_MINOR=0 ## Start of generic script part @@ -32,6 +32,25 @@ TEMPLATE_NAME=seqTemplateExample.sh MISSING_CONF=missingConf.log VERSION_STRING="${VERSION_REV}.${VERSION_MAJOR}.${VERSION_MINOR}" +BBLACK= ; [ -t 1 ] && BBLACK='\033[40m' +BLACK= ; [ -t 1 ] && BLACK='\033[0;30m' +DARKGRAY= ; [ -t 1 ] && DARKGRAY='\033[1;30m' +RED= ; [ -t 1 ] && RED='\033[0;31m' +LIGHTRED= ; [ -t 1 ] && LIGHTRED='\033[1;31m' +GREEN= ; [ -t 1 ] && GREEN='\033[0;32m' +LIGHTGREEN= ; [ -t 1 ] && LIGHTGREEN='\033[1;32m' +ORANGE= ; [ -t 1 ] && ORANGE='\033[0;33m' +YELLOW= ; [ -t 1 ] && YELLOW='\033[1;33m' +BLUE= ; [ -t 1 ] && BLUE='\033[0;34m' +LIGHTBLUE= ; [ -t 1 ] && LIGHTBLUE='\033[1;34m' +PURPLE= ; [ -t 1 ] && PURPLE='\033[0;35m' +LIGHTPURPLE= ; [ -t 1 ] && LIGHTPURPLE='\033[1;35m' +CYAN= ; [ -t 1 ] && CYAN='\033[0;36m' +LIGHTCYAN= ; [ -t 1 ] && LIGHTCYAN='\033[1;36m' +LIGHTGRAY= ; [ -t 1 ] && LIGHTGRAY='\033[0;37m' +WHITE= ; [ -t 1 ] && WHITE='\033[1;37m' +NC= ;[ -t 1 ] && NC='\033[0m' # No Color + helpSequencer() { cat <,<,|). Supporting: dry-run (-d): only print command without execution verbose (-v): print command before execution - exep "[COMMANDLINE]" +USAGE_API +echo -e "${GREEN} exep \"[COMMANDLINE]\"${NC}" +cat < [TEMPLATE] +USAGE_API +echo -e "${GREEN} initSeqConfig [OPTION] [TEMPLATE]${NC}" +cat < [SOURCE TYPE] +USAGE_API +echo -e "${GREEN} addConf [SOURCE TYPE] ${NC}" +cat <) to a destination file. If the CONFIGFILE exists, a backup (name_%Y%m%d-%H%M%S.bck) is saved at the same location. If -s fails or -m, "$(realpath "$MISSING_CONF")" is created with the conflicts @@ -145,30 +171,58 @@ sequencer.sh build-in functions: Target file to be created or modified. - step +USAGE_API +echo -e "${GREEN} step ${NC}" +cat < [DESCRIPTION] +USAGE_API +echo -e "${GREEN} endCheckEmpty [DESCRIPTION]${NC}" +cat < : Name used within eval [DESCRIPTION] : Additional text for error output - saveReturn [ERRORCODE] +USAGE_API +echo -e "${GREEN} saveReturn [ERRORCODE]${NC}" +cat <&2 echo "$@"; } +# outColor [BACKGROUND COLOR] +outColor() { + [ ! -t 1 ] && return 0 + case "$1" in + black) + tput setaf 0;; + red) + tput setaf 1;; + green) + tput setaf 2;; + yellow) + tput setaf 3;; + blue) + tput setaf 4;; + magenta) + tput setaf 5;; + cyan) + tput setaf 6;; + white) + tput setaf 7;; + *) + tput sgr0 + return;; + esac + + case "$2" in + black) + tput setab 0;; + red) + tput setab 1;; + green) + tput setab 2;; + yellow) + tput setab 3;; + blue) + tput setab 4;; + magenta) + tput setab 5;; + cyan) + tput setab 6;; + white) + tput setab 7;; + esac +} + # Echo additional line to info correctly indented INDENT_HELP=' : ' INDENTAPPEND_HELP=' ' @@ -355,7 +457,7 @@ initSeqConfig() { SEQ_CONFIG_HOME="$configDir" if [ -s "$configLoc" ] ; then - if [ $QUIET -ne 2 ] ; then echo " [I] Using configuration file: $configLoc" ; fi + [ $QUIET -ne 2 ] && echo " [I] Using configuration file: $configLoc" SEQ_CONFIG_FILE="$configLoc" . "$configLoc" return 0 @@ -546,6 +648,7 @@ execute() { existsFunction step_${1}_info if [ $? -eq 0 ] ; then step_${1}_info $1 "${STEP_ARGS[@]}" + outColor else # Add newline if no info is given echo @@ -579,6 +682,7 @@ execute() { step_$1 $1 "${STEP_ARGS[@]}" STEP_RETURN=$? fi + outColor } # checkStep @@ -629,6 +733,7 @@ step() { else step_$stepNo "${stepArgs[@]}" fi + outColor } # continous @@ -714,6 +819,9 @@ step_config() { #initSeqConfig -p "\$SCRIPT_NAME" "\$CONFIG_FILE_TEMPLATE" #if [ \$? -eq 0 ] ; then # CONFIG=1 + #else + # # End if no configuration file exists + # [ \$DRY -eq 0 ] && exit 1 #fi } @@ -828,7 +936,7 @@ displayHelp() { existsFunction step_${i}_alias if [ $? -eq 0 ] ; then step_${i}_alias - echo " = $ALIAS" + echo -e " = ${ORANGE}$ALIAS${NC}" printf '%s' "$INDENT_HELP" else echo -n " : " @@ -841,6 +949,7 @@ displayHelp() { else echo " - step_${i}_info() missing" fi + outColor done echo fi