diff --git a/sequencer/sequencer.sh b/sequencer/sequencer.sh index 09fbbea..4b3e567 100755 --- a/sequencer/sequencer.sh +++ b/sequencer/sequencer.sh @@ -8,8 +8,8 @@ ## Version information VERSION_REV=13 -VERSION_MAJOR=0 -VERSION_MINOR=1 +VERSION_MAJOR=1 +VERSION_MINOR=0 ## Start of generic script part @@ -26,9 +26,11 @@ ALIAS= CONTEXT_HELP=0 SEQ_CONFIG_EDIT=0 SEQ_CONFIG_NAME=".seqs" -SEQ_CONFIG_HOME="$HOME/$SEQ_CONFIG_NAME" SEQ_CONFIG_FILE= -SEQ_PROFILE_NAME=default +SEQ_CONFIG_HOME="$HOME/$SEQ_CONFIG_NAME" +SEQ_PROFILE_SUPPORT=0 +SEQ_PROFILE_NAME= +SEQ_PROFILE_LIST=0 TEMPLATE_NAME=seqTemplateExample.sh MISSING_CONF=missingConf.log VERSION_STRING="${VERSION_REV}.${VERSION_MAJOR}.${VERSION_MINOR}" @@ -65,6 +67,7 @@ Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS] [STEP ARGUMENTS] (e.g. exe,addconf,echerr,...) --profile, -p : Sequence configuration profile name (default: "default") (if supported by sequence) + -pl : List available profiles --quiet, -q : Don't ask for permission to execute steps If called without starting step number, only this help is shown -qq : Same as --quiet but suppresses regular sequencer.sh output @@ -420,6 +423,22 @@ endReturn() { fi } +# listProfiles [OPTION] +# List all available profiles for current user +# [OPTION] +# -q : only check for profile support +listProfiles() { + local file= + if [ $SEQ_PROFILE_SUPPORT -eq 0 ]; then + echoerr " [E] $0 does not support configuration profiles" + return 1 + fi + [ "$1" == "-q" ] && return 0 + for file in $(ls "$SEQ_CONFIG_HOME"); do + echo ${file%.*} + done +} + # initSeqConfig [OPTION] [TEMPLATE] # Create a configuration file in the users' home. # Source it if already existent @@ -457,6 +476,8 @@ initSeqConfig() { local configLoc="$SEQ_CONFIG_HOME/$1" if [ $seqProfiles -ne 0 ] ; then + SEQ_PROFILE_SUPPORT=1 + [ -z "$SEQ_PROFILE_NAME" ] && SEQ_PROFILE_NAME=default configLoc="$SEQ_CONFIG_HOME/$1/${SEQ_PROFILE_NAME}.cfg" fi local configDir="$(dirname $configLoc)" @@ -1033,27 +1054,27 @@ main() { --config|-c) # open sequence configuration file QUIET=2 SEQ_CONFIG_EDIT=1 - shift - ;; + shift;; --dry-run|-d) # shows what would be done DRY=1 SEQUENCER_ARGS+=" $1" - shift - ;; + shift;; --help|-h) # show only help displayHelp 1 - exit 0; - ;; + exit 0;; --helpapi|-ha) #show build-in functions helpApi - exit 0; - ;; + exit 0;; --profile|-p) # seq profile name SEQUENCER_ARGS+=" $1 $2" shift - SEQ_PROFILE_NAME="$1" - shift - ;; + # Cover the case when only -p is given without profile name + [ -z "$1" ] && SEQ_PROFILE_NAME=default || SEQ_PROFILE_NAME="$1" + shift;; + -pl) # List available profiles + QUIET=2 + SEQ_PROFILE_LIST=1 + shift;; --quiet|-q|-qq) # detect if option quiet is available SEQUENCER_ARGS+=" $1" if [ "$1" == "-qq" ] ; then @@ -1061,22 +1082,18 @@ main() { else QUIET=1 fi - shift - ;; + shift;; --single|-s) # execute only one step and stop SEQUENCER_ARGS+=" $1" SINGLE=1 - shift - ;; + shift;; --verbose|-v) # set verbose flag SEQUENCER_ARGS+=" $1" VERBOSE=1 - shift - ;; + shift;; --version) # version request showVersion - exit 0; - ;; + exit 0;; esac done @@ -1144,6 +1161,13 @@ main() { echoerr " [E] Sequence does not have a configuration file" return 1 fi + + # Check for profile support + if [ $SEQ_PROFILE_LIST -ne 0 ]; then + listProfiles; exit $? + elif [ ! -z "$SEQ_PROFILE_NAME" ]; then + listProfiles -q || exit 1 + fi # check if more than one step is given and select execution mode if [ $SINGLE -ne 0 ] ; then