WIP some more variable refactoring

This commit is contained in:
2022-05-29 18:36:42 +02:00
parent bf32e05725
commit 7de1f7673f

View File

@@ -30,11 +30,14 @@ set -o pipefail
readonly seq_invocation="$(printf '%q' "${0}")$( (($#)) && printf ' %q' "$@" || true)"
readonly seq_template="seqTemplate.sh"
readonly _seq_configDirName=".seqs"
_seq_configEdit=0
_seq_profileList=
_seq_stepReturn=255
seq_args=
seq_configFile= # Filled by initSeqConfig
seq_profileName=
_seq_profileList=
_seq_stepReturn=255
seq_configRoot="${HOME}/${_seq_configDirName}"
# May be overwritten by seq
seq_configName="${seq_fileName}.cfg"
@@ -49,9 +52,6 @@ set -o pipefail
sqr_args=
sqr_missingConf=missingConf.log
_sqr_configEdit=0
readonly _sqr_configDirName=".seqs"
_sqr_configRoot="${HOME}/${_sqr_configDirName}"
_sqr_contextHelp=0
_sqr_contextExe=0
_sqr_debug=0
@@ -244,7 +244,7 @@ USAGE_API
USAGE_API
echo -e "${col_green} initSeqConfig [OPTION] <NAME> [TEMPLATE]${col_off}"
cat <<USAGE_API
Create a configuration file in ${_sqr_configRoot}/ and source it if already existent.
Create a configuration file in ${seq_configRoot}/ and source it if already existent.
[OPTION]
-p : Use profiles
-t : Source config also if created from template
@@ -1133,12 +1133,12 @@ listSteps() {
# -q : only check for profile support
listProfiles() {
local file=
if [[ ${_sqr_configDirName} == $(basename "${_sqr_configRoot}") ]] ; then
error "${seq_name} does not have configuration profiles"
if [[ ${_seq_configDirName} == $(basename "${seq_configRoot}") ]] ; then
error -e "${seq_name} does not have configuration profiles"
return 1
fi
[[ "${1:-}" == "-q" ]] && return 0
for file in "${_sqr_configRoot}"/* ; do
for file in "${seq_configRoot}"/* ; do
file="$(basename -- "${file}")"
[[ ${file%.*} =~ ^${1:-.*} ]] && printf '%s\n' "${file%.*}"
done
@@ -1186,21 +1186,21 @@ initSeqConfig() {
esac
done
local configLoc="$_sqr_configRoot/$1"
local configLoc="$seq_configRoot/$1"
if [[ $seqProfiles -ne 0 ]] ; then
[ -z "$seq_profileName" ] && seq_profileName=default
configLoc="$_sqr_configRoot/$1/${seq_profileName}.cfg"
configLoc="$seq_configRoot/$1/${seq_profileName}.cfg"
fi
configDir="$(dirname -- "$configLoc")"
local configTemplate="$2"
# Don't create anything if only profiles should be listed
if [ -n "${_seq_profileList}" ] ; then
_sqr_configRoot="$configDir"
seq_configRoot="$configDir"
return 0
fi
_sqr_configRoot="$configDir"
seq_configRoot="$configDir"
if [ -s "$configLoc" ] ; then
info "Using configuration file: $configLoc"
@@ -1241,7 +1241,7 @@ initSeqConfig() {
endReturn -o $? "Failed to create configuration"
if [ $sourceAlways -eq 0 ] ; then
if [ $_sqr_configEdit -eq 0 ] ; then
if [ $_seq_configEdit -eq 0 ] ; then
warning "Seq configuration created from template but not used"
warning -a "Please modify \"$configLoc\" first"
fi
@@ -1444,7 +1444,7 @@ sqr::compatible() {
# exclude older versions if needed
if [ -n "${sqr_minVersion}" ] && [[ ${sqr_minVersion} -le 15 ]] ; then
error "Unsupported sequence revision (major changes in version 16)"
error -a "(Use 'seqUpgrade.sh $(readlink -f -- $0)' for a basic upgrade)"
error -a "(Use 'sequpgrade.sh $(readlink -f -- $0)' for a basic upgrade)"
showVersion
return 1
fi
@@ -1478,7 +1478,7 @@ sqr::main() {
startAll="-a"
shift ;;
--config|-c) # open sequence configuration file
_sqr_configEdit=1
_seq_configEdit=1
shift ;;
--debug)
_sqr_debug="1"
@@ -1531,6 +1531,7 @@ sqr::main() {
shift ;;
--version) # version request
showVersion
LOG_LEVEL=0 # suppress finish message
exit 0 ;;
esac
done
@@ -1544,7 +1545,7 @@ sqr::main() {
fi
# Don't show help if only configuration should be edited
[ ${_sqr_configEdit} -ne 0 ] && [ -z "${1:-}" ] && LOG_LEVEL=1
[ ${_seq_configEdit} -ne 0 ] && [ -z "${1:-}" ] && LOG_LEVEL=1
if [ -z "${1:-}" ] && [ $quickStartOne -eq 0 ] ; then
if ! quiet && [[ ${LOG_LEVEL} -ge $log_info ]] ; then
@@ -1594,7 +1595,7 @@ sqr::main() {
if exists -f seq_config ; then
# Create/edit configuration file
if [ $_sqr_configEdit -ne 0 ] ; then
if [ $_seq_configEdit -ne 0 ] ; then
# Suppress seq_config output for editing
quietSave=${LOG_LEVEL}
LOG_LEVEL=0
@@ -1616,7 +1617,7 @@ sqr::main() {
else
return 1
fi
elif [ ${_sqr_configEdit} -ne 0 ] ; then
elif [ ${_seq_configEdit} -ne 0 ] ; then
error "Sequence does not have a configuration file"
return 1
fi