yage
3fe01a7263
===================================================================== Increased non-scwrypts-runtime compatibility and improved clarity in user environments after sourcing the scwrypts.plugin.zsh. --- New Features ------------------------- - added experimental support for --output json - added 'scwrypts --list-groups' to output the SCWRYPTS_GROUPS value - added 'scwrypts --config' to be `eval`-ed in non-scwrypts-runtime zsh --- Changes ------------------------------ - removed config variables which pertained to old scwrypts - removed deprecated --no-log - cleaned up environment requirements and improved import saftey for scwrypts.plugin.zsh; scwrypts is now *required* on $PATH in order to work - refactored group configuration to match external group configuration (configuration now in scwrypts.scwrypts.zsh rather than zsh/lib/config.group.zsh) - plugins/kubectl now forces an unalias of `f` (for fluxcd) on load - the 'use' command now supports the '-c' short flag for ease of quick use - upgraded max supported python version to 3.12; dropped support for python 3.9 (>3.10 required) - remove old references to SCWRYPTS_ROOT in favour of SCWRYPTS_ROOT__scwrypts - SCWRYPTS_LOG_LEVEL setting is now forwarded when using the SCWRYPTS__RUN meta execution function
90 lines
2.2 KiB
Bash
90 lines
2.2 KiB
Bash
#####################################################################
|
|
|
|
DEPENDENCIES+=(fzf) # (extensible) list of PATH dependencies
|
|
REQUIRED_ENV+=() # (extensible) list of required environment variables
|
|
|
|
#####################################################################
|
|
|
|
source ${0:a:h}/colors.zsh
|
|
source ${0:a:h}/io.zsh
|
|
source ${0:a:h}/os.zsh
|
|
source ${0:a:h}/credits.zsh
|
|
|
|
#####################################################################
|
|
|
|
source ${0:a:h}/dependencies.zsh
|
|
source ${0:a:h}/environment.zsh
|
|
|
|
#####################################################################
|
|
|
|
CHECK_ENVIRONMENT() {
|
|
local OPTIONAL=0
|
|
|
|
while [[ $# -gt 0 ]]
|
|
do
|
|
case $1 in
|
|
--optional ) OPTIONAL=1 ;;
|
|
esac
|
|
shift 1
|
|
done
|
|
|
|
[[ $OPTIONAL -eq 1 ]] && E=WARNING || E=ERROR
|
|
|
|
local ENVIRONMENT_STATUS=0
|
|
|
|
__CHECK_DEPENDENCIES $DEPENDENCIES
|
|
local MISSING_DEPENDENCIES=$?
|
|
|
|
__CHECK_REQUIRED_ENV $REQUIRED_ENV
|
|
local MISSING_ENVIRONMENT_VARIABLES=$?
|
|
|
|
##########################################
|
|
|
|
local ERROR_MESSAGE=""
|
|
[[ $MISSING_DEPENDENCIES -ne 0 ]] && {
|
|
((ENVIRONMENT_STATUS+=1))
|
|
ERROR_MESSAGE+="\n$MISSING_DEPENDENCIES missing "
|
|
|
|
[[ $MISSING_DEPENDENCIES -eq 1 ]] \
|
|
&& ERROR_MESSAGE+='dependency' \
|
|
|| ERROR_MESSAGE+='dependencies' \
|
|
;
|
|
}
|
|
|
|
[[ $MISSING_ENVIRONMENT_VARIABLES -ne 0 ]] && {
|
|
((ENVIRONMENT_STATUS+=2))
|
|
ERROR_MESSAGE+="\n$MISSING_ENVIRONMENT_VARIABLES missing environment variable"
|
|
|
|
[[ $MISSING_ENVIRONMENT_VARIABLES -gt 1 ]] && ERROR_MESSAGE+=s
|
|
}
|
|
|
|
[ $IMPORT_ERRORS ] && [[ $IMPORT_ERRORS -ne 0 ]] && {
|
|
((ENVIRONMENT_STATUS+=4))
|
|
ERROR_MESSAGE+="\n$IMPORT_ERRORS import error"
|
|
|
|
[[ $IMPORT_ERRORS -gt 1 ]] && ERROR_MESSAGE+=s
|
|
}
|
|
|
|
##########################################
|
|
|
|
[[ ENVIRONMENT_STATUS -ne 0 ]] && [[ $OPTIONAL -eq 0 ]] && {
|
|
ERROR_MESSAGE=$(echo $ERROR_MESSAGE | sed '1d; s/^/ /')
|
|
$E "environment errors found (see above)\n$ERROR_MESSAGE"
|
|
}
|
|
|
|
[[ $MISSING_ENVIRONMENT_VARIABLES -ne 0 ]] && [[ $__SCWRYPT ]] && {
|
|
REMINDER "
|
|
to quickly update missing environment variables, run:
|
|
'scwrypts zsh/scwrypts/environment/edit'
|
|
"
|
|
}
|
|
|
|
[[ $ENVIRONMENT_STATUS -ne 0 ]] && [[ $NO_EXIT -ne 1 ]] && [[ $OPTIONAL -eq 0 ]] && {
|
|
exit $ENVIRONMENT_STATUS
|
|
}
|
|
|
|
return $ENVIRONMENT_STATUS
|
|
}
|
|
|
|
CHECK_ENVIRONMENT
|