sequencer - list profiles (-pl) with filter function
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
VERSION_REV=15
|
VERSION_REV=15
|
||||||
VERSION_MAJOR=3
|
VERSION_MAJOR=3
|
||||||
VERSION_MINOR=0
|
VERSION_MINOR=1
|
||||||
|
|
||||||
## Start of generic script part
|
## Start of generic script part
|
||||||
|
|
||||||
@@ -21,22 +21,21 @@ ERNO=0
|
|||||||
SEQUENCER_ARGS=
|
SEQUENCER_ARGS=
|
||||||
STEP_ARGS=
|
STEP_ARGS=
|
||||||
STEP_RETURN=255
|
STEP_RETURN=255
|
||||||
MAX_STEP=512
|
readonly MAX_STEP=512
|
||||||
ALIAS=
|
ALIAS=
|
||||||
CONTEXT_HELP=0
|
CONTEXT_HELP=0
|
||||||
CONTEXT_EXE=0
|
CONTEXT_EXE=0
|
||||||
SEQ_NAME="$_SQN_ALIAS"
|
SEQ_NAME="$_SQN_ALIAS"
|
||||||
[ -z "$SEQ_NAME" ] && SEQ_NAME="${0##*/}"
|
[ -z "$SEQ_NAME" ] && SEQ_NAME="${0##*/}"
|
||||||
SEQ_CONFIG_EDIT=0
|
SEQ_CONFIG_EDIT=0
|
||||||
SEQ_CONFIG_NAME=".seqs"
|
readonly SEQ_CONFIG_NAME=".seqs"
|
||||||
SEQ_CONFIG_FILE=
|
SEQ_CONFIG_FILE=
|
||||||
SEQ_CONFIG_HOME="$HOME/$SEQ_CONFIG_NAME"
|
SEQ_CONFIG_HOME="$HOME/$SEQ_CONFIG_NAME"
|
||||||
SEQ_PROFILE_SUPPORT=0
|
|
||||||
SEQ_PROFILE_NAME=
|
SEQ_PROFILE_NAME=
|
||||||
SEQ_PROFILE_LIST=0
|
SEQ_PROFILE_LIST=
|
||||||
TEMPLATE_NAME=seqTemplateExample.sh
|
readonly TEMPLATE_NAME=seqTemplateExample.sh
|
||||||
MISSING_CONF=missingConf.log
|
readonly MISSING_CONF=missingConf.log
|
||||||
VERSION_STRING="${VERSION_REV}.${VERSION_MAJOR}.${VERSION_MINOR}"
|
readonly VERSION_STRING="${VERSION_REV}.${VERSION_MAJOR}.${VERSION_MINOR}"
|
||||||
DEFAULT_EDITOR_SYSTEM=
|
DEFAULT_EDITOR_SYSTEM=
|
||||||
|
|
||||||
BBLACK= ; [ -t 1 ] && BBLACK='\033[40m'
|
BBLACK= ; [ -t 1 ] && BBLACK='\033[40m'
|
||||||
@@ -476,20 +475,22 @@ endReturn() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# listProfiles [OPTION]
|
# listProfiles [OPTION] [SEARCH]
|
||||||
# List all available profiles for current user
|
# List all available profiles for current user
|
||||||
# [OPTION]
|
# [OPTION]
|
||||||
# -q : only check for profile support
|
# -q : only check for profile support
|
||||||
listProfiles() {
|
listProfiles() {
|
||||||
local file=
|
local file=
|
||||||
if [ $SEQ_PROFILE_SUPPORT -eq 0 ]; then
|
local profiles=()
|
||||||
echoerr " [E] $0 does not support configuration profiles"
|
if [[ $SEQ_CONFIG_NAME == $(basename "$SEQ_CONFIG_HOME") ]] ; then
|
||||||
|
echoerr " [E] $SEQ_NAME does not have configuration profiles"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
[ "$1" == "-q" ] && return 0
|
[[ "$1" == "-q" ]] && return 0
|
||||||
for file in $(ls "$SEQ_CONFIG_HOME"); do
|
for file in $(ls "$SEQ_CONFIG_HOME"); do
|
||||||
echo ${file%.*}
|
[[ ${file%.*} =~ ^${1:-".*"} ]] && profiles+=(${file%.*})
|
||||||
done
|
done
|
||||||
|
printf '%s\n' "${profiles[*]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# initSeqConfig [OPTION] <NAME> [TEMPLATE]
|
# initSeqConfig [OPTION] <NAME> [TEMPLATE]
|
||||||
@@ -531,7 +532,6 @@ initSeqConfig() {
|
|||||||
|
|
||||||
local configLoc="$SEQ_CONFIG_HOME/$1"
|
local configLoc="$SEQ_CONFIG_HOME/$1"
|
||||||
if [ $seqProfiles -ne 0 ] ; then
|
if [ $seqProfiles -ne 0 ] ; then
|
||||||
SEQ_PROFILE_SUPPORT=1
|
|
||||||
[ -z "$SEQ_PROFILE_NAME" ] && SEQ_PROFILE_NAME=default
|
[ -z "$SEQ_PROFILE_NAME" ] && SEQ_PROFILE_NAME=default
|
||||||
configLoc="$SEQ_CONFIG_HOME/$1/${SEQ_PROFILE_NAME}.cfg"
|
configLoc="$SEQ_CONFIG_HOME/$1/${SEQ_PROFILE_NAME}.cfg"
|
||||||
fi
|
fi
|
||||||
@@ -1242,9 +1242,10 @@ main() {
|
|||||||
# Cover the case when only -p is given without profile name
|
# Cover the case when only -p is given without profile name
|
||||||
[ -z "$1" ] && SEQ_PROFILE_NAME=default || SEQ_PROFILE_NAME="$1"
|
[ -z "$1" ] && SEQ_PROFILE_NAME=default || SEQ_PROFILE_NAME="$1"
|
||||||
shift;;
|
shift;;
|
||||||
-pl) # List available profiles
|
-pl) # List available profiles with search
|
||||||
|
shift
|
||||||
QUIET=2
|
QUIET=2
|
||||||
SEQ_PROFILE_LIST=1
|
SEQ_PROFILE_LIST="${1:-".*"}"
|
||||||
shift;;
|
shift;;
|
||||||
--quiet|-q|-qq) # detect if option quiet is available
|
--quiet|-q|-qq) # detect if option quiet is available
|
||||||
SEQUENCER_ARGS+=" $1"
|
SEQUENCER_ARGS+=" $1"
|
||||||
@@ -1359,8 +1360,8 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for profile support
|
# Check for profile support
|
||||||
if [ $SEQ_PROFILE_LIST -ne 0 ]; then
|
if [ -n "$SEQ_PROFILE_LIST" ]; then
|
||||||
listProfiles; exit $?
|
listProfiles "${SEQ_PROFILE_LIST}"; exit $?
|
||||||
elif [ -n "$SEQ_PROFILE_NAME" ]; then
|
elif [ -n "$SEQ_PROFILE_NAME" ]; then
|
||||||
listProfiles -q || exit 1
|
listProfiles -q || exit 1
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user