Sequencer new option to open sequence config file when initialised using initSeqConfig
Sequences with exit in step_config, changed to return to support opening config file on first run
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
## Version information
|
||||
|
||||
VERSION_REV=12
|
||||
VERSION_MAJOR=1
|
||||
VERSION_MAJOR=2
|
||||
VERSION_MINOR=0
|
||||
|
||||
## Start of generic script part
|
||||
@@ -24,6 +24,7 @@ STEP_RETURN=255
|
||||
MAX_STEP=512
|
||||
ALIAS=
|
||||
CONTEXT_HELP=0
|
||||
SEQ_CONFIG_EDIT=0
|
||||
SEQ_CONFIG_NAME=".seqs"
|
||||
SEQ_CONFIG_HOME="$HOME/$SEQ_CONFIG_NAME"
|
||||
SEQ_CONFIG_FILE=
|
||||
@@ -56,6 +57,7 @@ helpSequencer() {
|
||||
Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS] [STEP ARGUMENTS]
|
||||
|
||||
[OPTIONS]
|
||||
--config, -c : Open sequence configuration file (also sets -qq)
|
||||
--dry-run, -d : Only print to console what would be done
|
||||
! Attention - Sequence must support this
|
||||
--help, -h : Display help
|
||||
@@ -449,8 +451,8 @@ initSeqConfig() {
|
||||
|
||||
# Create config subdir in users home
|
||||
if [ ! -e "$configDir/" ] ; then
|
||||
echo -n " [I] Creating $(realpath $configDir)..."
|
||||
exe mkdir -p "$configDir" && echo "Ok" || echo "Nok"
|
||||
echoseq -n " [I] Creating $(realpath $configDir)..."
|
||||
exe mkdir -p "$configDir" && echoseq "Ok" || echoseq "Nok"
|
||||
exe chmod 700 "$configDir"
|
||||
fi
|
||||
|
||||
@@ -483,8 +485,11 @@ initSeqConfig() {
|
||||
exe chmod 600 "$configLoc"
|
||||
|
||||
if [ $sourceAlways -eq 0 ] ; then
|
||||
echoerr " [W] Seq configuration created from template but not used"
|
||||
echoerr " Please modify "$configLoc" first and restart sequence"
|
||||
if [ $SEQ_CONFIG_EDIT -eq 0 ] ; then
|
||||
echoerr " [W] Seq configuration created from template but not used"
|
||||
echoerr " Please modify "$configLoc" first and restart sequence"
|
||||
fi
|
||||
SEQ_CONFIG_FILE="$configLoc"
|
||||
return 1
|
||||
else
|
||||
echo " [W] Using seq configuration from template $configTemplate"
|
||||
@@ -821,7 +826,7 @@ step_config() {
|
||||
# CONFIG=1
|
||||
#else
|
||||
# # End if no configuration file exists
|
||||
# [ \$DRY -eq 0 ] && exit 1
|
||||
# [ \$DRY -eq 0 ] && return -1
|
||||
#fi
|
||||
}
|
||||
|
||||
@@ -1003,6 +1008,11 @@ main() {
|
||||
# options check
|
||||
for arg in "$@" ; do
|
||||
case "$1" in
|
||||
--config|-c) # open sequence configuration file
|
||||
QUIET=2
|
||||
SEQ_CONFIG_EDIT=1
|
||||
shift
|
||||
;;
|
||||
--dry-run|-d) # shows what would be done
|
||||
DRY=1
|
||||
SEQUENCER_ARGS+=" $1"
|
||||
@@ -1091,10 +1101,17 @@ main() {
|
||||
# run configuration for seq only if available and if first step is valid
|
||||
existsFunction step_config
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ $SEQ_CONFIG_EDIT -ne 0 ] ; then
|
||||
step_config "${STEP_ARGS[@]}"
|
||||
[ -w "$SEQ_CONFIG_FILE" ] && vi "$SEQ_CONFIG_FILE" \
|
||||
|| echoerr " [E] No configuration file available"
|
||||
exit 0
|
||||
fi
|
||||
checkStep "${START[0]}"
|
||||
if [ $? -ne 0 ] ; then
|
||||
if [ $QUIET -ne 2 ] ; then echo " [I] Configuring sequence (step_config) ..." ; fi
|
||||
step_config "${STEP_ARGS[@]}"
|
||||
[ $? -ne 0 ] && exit 1
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
Reference in New Issue
Block a user