Compare commits
No commits in common. "b796021357a87067527760f81509f07e23999ea2" and "4146a0d2972c11fea4e49d72fb6011e0ab750bbb" have entirely different histories.
b796021357
...
4146a0d297
@ -12,6 +12,10 @@ export DISCORD__DEFAULT_AVATAR_URL=
|
||||
export DISCORD__DEFAULT_CHANNEL_ID=
|
||||
export DISCORD__DEFAULT_USERNAME=
|
||||
export DISCORD__DEFAULT_WEBHOOK=
|
||||
export I3__BORDER_PIXEL_SIZE=
|
||||
export I3__DMENU_FONT_SIZE=
|
||||
export I3__GLOBAL_FONT_SIZE=
|
||||
export I3__MODEL_CONFIG=
|
||||
export LINEAR__API_TOKEN=
|
||||
export MEDIA_SYNC__S3_BUCKET
|
||||
export MEDIA_SYNC__TARGETS
|
||||
|
@ -15,6 +15,11 @@ DISCORD__DEFAULT_CHANNEL_ID |
|
||||
DISCORD__DEFAULT_USERNAME |
|
||||
DISCORD__DEFAULT_WEBHOOK |
|
||||
|
||||
I3__BORDER_PIXEL_SIZE | custom i3 configuration settings
|
||||
I3__DMENU_FONT_SIZE |
|
||||
I3__GLOBAL_FONT_SIZE |
|
||||
I3__MODEL_CONFIG |
|
||||
|
||||
LINEAR__API_TOKEN | linear.app project management configuration
|
||||
|
||||
MEDIA_SYNC__S3_BUCKET | s3 bucket name and filesystem targets for media backups
|
||||
|
@ -1,10 +1,11 @@
|
||||
[[ $SCWRYPTS_KUBECTL_DRIVER_READY -eq 1 ]] && return 0
|
||||
|
||||
unalias k h f >/dev/null 2>&1
|
||||
unalias k h >/dev/null 2>&1
|
||||
k() { _SCWRYPTS_KUBECTL_DRIVER kubectl $@; }
|
||||
h() { _SCWRYPTS_KUBECTL_DRIVER helm $@; }
|
||||
f() { _SCWRYPTS_KUBECTL_DRIVER flux $@; }
|
||||
|
||||
|
||||
_SCWRYPTS_KUBECTL_DRIVER() {
|
||||
[ ! $SCWRYPTS_ENV ] && {
|
||||
ERROR "must set SCWRYPTS_ENV in order to use '$(echo $CLI | head -c1)'"
|
||||
|
@ -4,7 +4,7 @@ from .scwrypts.exceptions import MissingVariableError
|
||||
|
||||
|
||||
def getenv(name, required=True):
|
||||
value = os_getenv(f'{name}__override', os_getenv(name))
|
||||
value = os_getenv(name, None)
|
||||
|
||||
if required and not value:
|
||||
raise MissingVariableError(name)
|
||||
|
117
scwrypts
117
scwrypts
@ -1,6 +1,5 @@
|
||||
#!/bin/zsh
|
||||
export EXECUTION_DIR=$(pwd)
|
||||
export SCWRYPTS_RUNTIME_ID=$(uuidgen)
|
||||
source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
#####################################################################
|
||||
() {
|
||||
@ -22,7 +21,6 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
runtime
|
||||
-y, --yes auto-accept all [yn] prompts through current scwrypt
|
||||
-e, --env <env-name> set environment; overwrites SCWRYPTS_ENV
|
||||
|
||||
-n shorthand for "--log-level 0"
|
||||
-v, --log-level [0-4] set incremental scwrypts log level to one of the following:
|
||||
0 : only command output and critical failures; skips logfile
|
||||
@ -31,19 +29,13 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
3 : (default) include warning messages
|
||||
4 : include debug messages
|
||||
|
||||
-o, --output specify output format; one of:
|
||||
pretty (default)
|
||||
json (experimental)
|
||||
|
||||
alternate commands
|
||||
-h, --help display this message and exit
|
||||
-l, --list print out command list and exit
|
||||
--list-envs print out environment list and exit
|
||||
--list-groups print out configured scwrypts groups and exit
|
||||
--config "eval"-ed to enable config and "use" import in non-scwrypts environments
|
||||
--root print out SCWRYPTS_ROOT__scwrypts and exit
|
||||
--update update scwrypts library to latest version
|
||||
--version print out scwrypts version and exit
|
||||
-h, --help display this message and exit
|
||||
-l, --list print out command list and exit
|
||||
--list-envs print out environment list and exit
|
||||
--root print out SCWRYPTS_ROOT__scwrypts and exit
|
||||
--update update scwrypts library to latest version
|
||||
--version print out scwrypts version and exit
|
||||
|
||||
patterns:
|
||||
- a list of glob patterns to loose-match a scwrypt by name
|
||||
@ -64,10 +56,8 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
|
||||
[ ! $SCWRYPTS_LOG_LEVEL ] && local SCWRYPTS_LOG_LEVEL=3
|
||||
|
||||
local SHIFT_COUNT
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
SHIFT_COUNT=1
|
||||
case $1 in
|
||||
-[a-z][a-z]* )
|
||||
VARSPLIT=$(echo "$1 " | sed 's/^\(-.\)\(.*\) /\1 -\2/')
|
||||
@ -91,11 +81,6 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
return 0
|
||||
;;
|
||||
|
||||
--list-groups )
|
||||
echo "${SCWRYPTS_GROUPS[@]}" | sed 's/\s\+/\n/g' | sort -u
|
||||
return 0
|
||||
;;
|
||||
|
||||
--version )
|
||||
case $SCWRYPTS_INSTALLATION_TYPE in
|
||||
manual ) echo "scwrypts $(GIT_SCWRYPTS describe --tags) (via GIT)" ;;
|
||||
@ -109,13 +94,6 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
return 0
|
||||
;;
|
||||
|
||||
--config )
|
||||
echo "source '$SCWRYPTS_ROOT__scwrypts/zsh/lib/import.driver.zsh'"
|
||||
echo "CHECK_ENVIRONMENT --no-fail --no-usage"
|
||||
echo "unset __SCWRYPT"
|
||||
return 0
|
||||
;;
|
||||
|
||||
--update )
|
||||
case $SCWRYPTS_INSTALLATION_TYPE in
|
||||
aur )
|
||||
@ -126,7 +104,7 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
;;
|
||||
|
||||
homebrew )
|
||||
SCWRYPTS_LOG_LEVEL=3 REMINDER "This installation is managed by homebrew. Update me with 'brew update'"
|
||||
SCWRYPTS_LOG_LEVEL=3 REMINDER "This installation is managed by homebrew. Update me with 'brew update scwrypts'"
|
||||
;;
|
||||
|
||||
manual )
|
||||
@ -164,52 +142,46 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
### scwrypts filters #####################
|
||||
|
||||
-m | --name )
|
||||
((SHIFT_COUNT+=1))
|
||||
[ $2 ] || { ERROR "missing value for argument $1"; break; }
|
||||
SEARCH_NAME=$2
|
||||
shift 1
|
||||
;;
|
||||
|
||||
-g | --group )
|
||||
((SHIFT_COUNT+=1))
|
||||
[ $2 ] || { ERROR "missing value for argument $1"; break; }
|
||||
SEARCH_GROUP=$2
|
||||
shift 1
|
||||
;;
|
||||
|
||||
-t | --type )
|
||||
((SHIFT_COUNT+=1))
|
||||
[ $2 ] || { ERROR "missing value for argument $1"; break; }
|
||||
SEARCH_TYPE=$2
|
||||
shift 1
|
||||
;;
|
||||
|
||||
### runtime settings #####################
|
||||
|
||||
-y | --yes ) export __SCWRYPTS_YES=1 ;;
|
||||
|
||||
-n ) SCWRYPTS_LOG_LEVEL=0 ;;
|
||||
|
||||
-v | --log-level )
|
||||
((SHIFT_COUNT+=1))
|
||||
[[ $2 =~ ^[0-4]$ ]] || ERROR "invalid setting for log-level '$2'"
|
||||
SCWRYPTS_LOG_LEVEL=$2
|
||||
-n | --no-log )
|
||||
SCWRYPTS_LOG_LEVEL=0
|
||||
[[ $1 =~ ^--no-log$ ]] && WARNING 'the --no-log flag is deprecated and will be removed in scwrypts v4.2'
|
||||
;;
|
||||
|
||||
-o | --output )
|
||||
((SHIFT_COUNT+=1))
|
||||
export SCWRYPTS_OUTPUT_FORMAT=$2
|
||||
case $SCWRYPTS_OUTPUT_FORMAT in
|
||||
pretty | json ) ;;
|
||||
* ) ERROR "unsupported format '$SCWRYPTS_OUTPUT_FORMAT'" ;;
|
||||
esac
|
||||
-v | --log-level )
|
||||
[[ $2 =~ ^[0-4]$ ]] || ERROR "invalid setting for log-level '$2'"
|
||||
SCWRYPTS_LOG_LEVEL=$2
|
||||
shift 1
|
||||
;;
|
||||
|
||||
-e | --env )
|
||||
((SHIFT_COUNT+=1))
|
||||
[ $2 ] || { ERROR "missing value for argument $1"; break; }
|
||||
|
||||
[ $ENV_NAME ] && DEBUG 'overwriting session environment'
|
||||
|
||||
ENV_NAME="$2"
|
||||
STATUS "using CLI environment '$ENV_NAME'"
|
||||
shift 1
|
||||
;;
|
||||
|
||||
##########################################
|
||||
@ -218,11 +190,9 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
--* ) ERROR "unrecognized argument '$1'" ;;
|
||||
* ) SEARCH_PATTERNS+=($1) ;;
|
||||
esac
|
||||
shift $SHIFT_COUNT
|
||||
shift 1
|
||||
done
|
||||
|
||||
[ $SCWRYPTS_OUTPUT_FORMAT ] || export SCWRYPTS_OUTPUT_FORMAT=pretty
|
||||
|
||||
[ $SEARCH_NAME ] && {
|
||||
[ $SEARCH_TYPE ] || ERROR '--name requires --type argument'
|
||||
[ $SEARCH_GROUP ] || ERROR '--name requires --group argument'
|
||||
@ -414,42 +384,25 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
[[ $SCWRYPT_NAME =~ interactive ]] && RUN_MODE=interactive
|
||||
|
||||
local HEADER FOOTER
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 2 ]] && {
|
||||
case $SCWRYPTS_OUTPUT_FORMAT in
|
||||
pretty )
|
||||
HEADER=$(
|
||||
echo "
|
||||
=====================================================================
|
||||
scwrypt : $SCWRYPT_GROUP $SCWRYPT_TYPE $SCWRYPT_NAME
|
||||
run at : $(date)
|
||||
config : $ENV_NAME
|
||||
log level : $SCWRYPTS_LOG_LEVEL
|
||||
\\033[1;33m--- SCWRYPT BEGIN ---------------------------------------------------\\033[0m
|
||||
" | sed 's/^\s\+//; 1d'
|
||||
)
|
||||
|
||||
FOOTER="\\033[1;33m--- SCWRYPT END ---------------------------------------------------\\033[0m"
|
||||
;;
|
||||
json )
|
||||
HEADER=$(echo '{}' | jq -c ".
|
||||
| .timestamp = \"$(date +%s)\"
|
||||
| .runtime = \"$SCWRYPTS_RUNTIME_ID\"
|
||||
| .scwrypt = \"start of $SCWRYPT_NAME $SCWRYPT_GROUP $SCWRYPT_TYPE\"
|
||||
| .config = \"$ENV_NAME\"
|
||||
| .logLevel = \"$SCWRYPTS_LOG_LEVEL\"
|
||||
| .subscwrypt = $SUBSCWRYPT
|
||||
")
|
||||
;;
|
||||
esac
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 2 ]] && {
|
||||
HEADER=$(
|
||||
echo "
|
||||
=====================================================================
|
||||
script : $SCWRYPT_GROUP $SCWRYPT_TYPE $SCWRYPT_NAME
|
||||
run at : $(date)
|
||||
config : $ENV_NAME
|
||||
log level : $SCWRYPTS_LOG_LEVEL
|
||||
\\033[1;33m--- SCWRYPT BEGIN ---------------------------------------------------\\033[0m
|
||||
" | sed 's/^\s\+//; 1d'
|
||||
)
|
||||
|
||||
FOOTER="\\033[1;33m--- SCWRYPT END ---------------------------------------------------\\033[0m"
|
||||
}
|
||||
|
||||
[[ $SUBSCWRYPT -eq 0 ]] || {
|
||||
case $SCWRYPTS_OUTPUT_FORMAT in
|
||||
pretty )
|
||||
HEADER="\\033[0;33m--- ($SUBSCWRYPT) BEGIN $SCWRYPT_GROUP $SCWRYPT_TYPE $SCWRYPT_NAME ---"
|
||||
FOOTER="\\033[0;33m--- ($SUBSCWRYPT) END $SCWRYPT_GROUP $SCWRYPT_TYPE $SCWRYPT_NAME ---"
|
||||
;;
|
||||
esac
|
||||
HEADER="\\033[0;33m--- ($SUBSCWRYPT) BEGIN $SCWRYPT_GROUP $SCWRYPT_TYPE $SCWRYPT_NAME ---"
|
||||
FOOTER="\\033[0;33m--- ($SUBSCWRYPT) END $SCWRYPT_GROUP $SCWRYPT_TYPE $SCWRYPT_NAME ---"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
@ -480,5 +433,5 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
|
||||
&& echo "terminated with\\033[1;$EXIT_COLOR code $EXIT_CODE\\033[0m"
|
||||
|
||||
return $EXIT_CODE
|
||||
} | tee --append "$LOGFILE"
|
||||
} 2>&1 | tee --append "$LOGFILE"
|
||||
} $@
|
||||
|
@ -2,44 +2,47 @@
|
||||
|
||||
: \
|
||||
&& command -v scwrypts &>/dev/null \
|
||||
&& eval "$(scwrypts --config)" \
|
||||
&& source "$(scwrypts --root)/zsh/lib/import.driver.zsh" \
|
||||
&& unset __SCWRYPT \
|
||||
|| {
|
||||
echo 'scwrypts must be in PATH and properly configured; skipping zsh plugin setup' >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
__SCWRYPTS_PARSE() {
|
||||
SCWRYPT_SELECTION=$(scwrypts --list | fzf --prompt 'select a script : ' --header-lines 1)
|
||||
LBUFFER= RBUFFER=
|
||||
[ $SCWRYPT_SELECTION ] || return 1
|
||||
|
||||
NAME=$(echo "$SCWRYPT_SELECTION" | awk '{print $1;}')
|
||||
TYPE=$(echo "$SCWRYPT_SELECTION" | awk '{print $2;}')
|
||||
GROUP=$(echo "$SCWRYPT_SELECTION" | awk '{print $3;}')
|
||||
|
||||
[ $NAME ] && [ $TYPE ] && [ $GROUP ]
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
SCWRYPTS__ZSH_PLUGIN() {
|
||||
local SCWRYPT_SELECTION NAME TYPE GROUP
|
||||
__SCWRYPTS_PARSE || { zle accept-line; return 0; }
|
||||
local SCWRYPT_SELECTION=$(scwrypts --list | FZF 'select a script' --header-lines 1)
|
||||
local NAME
|
||||
local TYPE
|
||||
local GROUP
|
||||
LBUFFER= RBUFFER=
|
||||
[ ! $SCWRYPT_SELECTION ] && { zle accept-line; return 0; }
|
||||
|
||||
RBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP"
|
||||
SCWRYPTS__SEPARATE_SCWRYPT_SELECTION $SCWRYPT_SELECTION
|
||||
|
||||
which scwrypts >/dev/null 2>&1\
|
||||
&& RBUFFER="scwrypts" || RBUFFER="$SCWRYPTS_ROOT/scwrypts"
|
||||
|
||||
RBUFFER+=" --name $NAME --group $GROUP --type $TYPE"
|
||||
zle accept-line
|
||||
}
|
||||
|
||||
zle -N scwrypts SCWRYPTS__ZSH_PLUGIN
|
||||
bindkey $SCWRYPTS_SHORTCUT scwrypts
|
||||
unset SCWRYPTS_SHORTCUT
|
||||
|
||||
#####################################################################
|
||||
|
||||
SCWRYPTS__ZSH_BUILDER_PLUGIN() {
|
||||
local SCWRYPT_SELECTION NAME TYPE GROUP
|
||||
__SCWRYPTS_PARSE || { echo >&2; zle accept-line; return 0; }
|
||||
local SCWRYPT_SELECTION=$(scwrypts --list | FZF 'select a script' --header-lines 1)
|
||||
echo $SCWRYPT_SELECTION >&2
|
||||
local NAME
|
||||
local TYPE
|
||||
local GROUP
|
||||
LBUFFER= RBUFFER=
|
||||
[ ! $SCWRYPT_SELECTION ] && { zle accept-line; return 0; }
|
||||
|
||||
SCWRYPTS__SEPARATE_SCWRYPT_SELECTION $SCWRYPT_SELECTION
|
||||
|
||||
scwrypts -n --name $NAME --group $GROUP --type $TYPE -- --help >&2 || {
|
||||
zle accept-line
|
||||
@ -48,20 +51,22 @@ SCWRYPTS__ZSH_BUILDER_PLUGIN() {
|
||||
echo
|
||||
|
||||
zle reset-prompt
|
||||
LBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP -- "
|
||||
which scwrypts >/dev/null 2>&1\
|
||||
&& LBUFFER="scwrypts" || LBUFFER="$SCWRYPTS_ROOT/scwrypts"
|
||||
|
||||
LBUFFER+=" --name $NAME --group $GROUP --type $TYPE -- "
|
||||
}
|
||||
|
||||
zle -N scwrypts-builder SCWRYPTS__ZSH_BUILDER_PLUGIN
|
||||
bindkey $SCWRYPTS_BUILDER_SHORTCUT scwrypts-builder
|
||||
unset SCWRYPTS_BUILDER_SHORTCUT
|
||||
|
||||
#####################################################################
|
||||
|
||||
SCWRYPTS__ZSH_PLUGIN_ENV() {
|
||||
local RESET='reset'
|
||||
local SELECTED=$(\
|
||||
{ [ $SCWRYPTS_ENV ] && echo $RESET; scwrypts --list-envs; } \
|
||||
| fzf --prompt 'select an environment : ' \
|
||||
{ [ $SCWRYPTS_ENV ] && echo $RESET; SCWRYPTS__GET_ENV_NAMES; } \
|
||||
| FZF 'select an environment' \
|
||||
)
|
||||
|
||||
zle clear-command-line
|
||||
@ -75,6 +80,3 @@ SCWRYPTS__ZSH_PLUGIN_ENV() {
|
||||
|
||||
zle -N scwrypts-setenv SCWRYPTS__ZSH_PLUGIN_ENV
|
||||
bindkey $SCWRYPTS_ENV_SHORTCUT scwrypts-setenv
|
||||
unset SCWRYPTS_ENV_SHORTCUT
|
||||
|
||||
#####################################################################
|
||||
|
@ -1,11 +0,0 @@
|
||||
SCWRYPTS_GROUPS+=(scwrypts)
|
||||
|
||||
export SCWRYPTS_ROOT__scwrypts="$SCWRYPTS_ROOT"
|
||||
export SCWRYPTS_COLOR__scwrypts='\033[0;32m'
|
||||
#export SCWRYPTS_TYPE__scwrypts=
|
||||
#export SCWRYPTS_LIBRARY_ROOT__scwrypts=
|
||||
|
||||
export SCWRYPTS_VIRTUALENV_PATH__scwrypts="$SCWRYPTS_DATA_PATH/virtualenv"
|
||||
|
||||
export SCWRYPTS_PREFERRED_PYTHON_VERSIONS__scwrypts=(3.12 3.11 3.10)
|
||||
export SCWRYPTS_NODE_VERSION__scwrypts=18.0.0
|
10
zsh/lib/config.group.zsh
Normal file
10
zsh/lib/config.group.zsh
Normal file
@ -0,0 +1,10 @@
|
||||
export SCWRYPTS_ROOT__scwrypts="$SCWRYPTS_ROOT"
|
||||
export SCWRYPTS_LIBRARY_ROOT__scwrypts="$SCWRYPTS_ROOT/zsh/lib"
|
||||
export SCWRYPTS_COLOR__scwrypts='\033[0;32m'
|
||||
|
||||
|
||||
export SCWRYPTS_VIRTUALENV_PATH__scwrypts="$SCWRYPTS_DATA_PATH/virtualenv"
|
||||
[ ! -d "$SCWRYPTS_VIRTUALENV_PATH__scwrypts" ] && mkdir -p "$SCWRYPTS_VIRTUALENV_PATH__scwrypts"
|
||||
|
||||
export SCWRYPTS_PREFERRED_PYTHON_VERSIONS__scwrypts=(3.11 3.10 3.9)
|
||||
export SCWRYPTS_NODE_VERSION__scwrypts=18.0.0
|
@ -53,10 +53,10 @@ export \
|
||||
SCWRYPTS_OUTPUT_PATH \
|
||||
;
|
||||
|
||||
source "$SCWRYPTS_ROOT/scwrypts.scwrypts.zsh" \
|
||||
|| FAIL 69 'failed to set up scwrypts group; aborting'
|
||||
SCWRYPTS_GROUPS=(scwrypts $(echo $SCWRYPTS_GROUPS | sed 's/\s\+/\n/g' | sort -u))
|
||||
|
||||
SCWRYPTS_GROUPS=(scwrypts $(echo $SCWRYPTS_GROUPS | sed 's/\s\+/\n/g' | sort -u | grep -v '^scwrypts$'))
|
||||
source "$SCWRYPTS_ROOT/zsh/lib/config.group.zsh" \
|
||||
|| FAIL 69 'failed to set up scwrypts group; aborting'
|
||||
|
||||
#####################################################################
|
||||
|
||||
|
@ -34,7 +34,7 @@ source "${0:a:h}/config.zsh"
|
||||
|
||||
use() {
|
||||
local SCWRYPTS_LIBRARY SCWRYPTS_LIBRARY_ROOT SCWRYPTS_LIBRARY_GROUP
|
||||
local DEFER_ENVIRONMENT_CHECK=true
|
||||
local DEFER_ENVIRONMENT_CHECK=1
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
@ -49,8 +49,8 @@ use() {
|
||||
SCWRYPTS_LIBRARY_ROOT=$2
|
||||
shift 1
|
||||
;;
|
||||
-c | --check-environment )
|
||||
DEFER_ENVIRONMENT_CHECK=false
|
||||
--check-environment )
|
||||
DEFER_ENVIRONMENT_CHECK=0
|
||||
;;
|
||||
* )
|
||||
[ ! $SCWRYPTS_LIBRARY ] \
|
||||
@ -106,7 +106,7 @@ use() {
|
||||
return 1
|
||||
}
|
||||
|
||||
[[ $DEFER_ENVIRONMENT_CHECK =~ false ]] && {
|
||||
[[ $DEFER_ENVIRONMENT_CHECK -eq 0 ]] && {
|
||||
CHECK_ENVIRONMENT || {
|
||||
((IMPORT_ERRORS+=1))
|
||||
ERROR "import error for '$SCWRYPTS_LIBRARY_GROUP/$SCWRYPTS_LIBRARY'"
|
||||
|
@ -74,8 +74,6 @@ _VIRTUALENV__GET_PATH() {
|
||||
local ENV_PATH="$(eval echo '$SCWRYPTS_VIRTUALENV_PATH__'$GROUP 2>/dev/null)"
|
||||
[ ! $ENV_PATH ] && ENV_PATH="$SCWRYPTS_VIRTUALENV_PATH__scwrypts"
|
||||
|
||||
mkdir -p "$ENV_PATH/$TYPE" &>/dev/null
|
||||
|
||||
echo $ENV_PATH/$TYPE
|
||||
}
|
||||
|
||||
@ -97,7 +95,7 @@ CREATE_VIRTUALENV__scwrypts__py() {
|
||||
}
|
||||
done
|
||||
[ ! $PYTHON ] && {
|
||||
ERROR 'python>=3.10 not available; skipping python env'
|
||||
ERROR 'python>=3.9 not available; skipping python env'
|
||||
return 1
|
||||
}
|
||||
|
||||
|
@ -5,61 +5,34 @@ PRINT() {
|
||||
local STDOUT=0
|
||||
|
||||
local LTRIM=1
|
||||
local FORMAT=$SCWRYPTS_OUTPUT_FORMAT
|
||||
local _S
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
_S=1
|
||||
case $1 in
|
||||
-n | --no-trim-tabs ) LTRIM=0 ;;
|
||||
-x | --no-line-end ) LAST_LINE_END='' ;;
|
||||
-o | --use-stdout ) STDOUT=1; STDERR=0 ;;
|
||||
|
||||
-f | --format ) ((_S+=1)); FORMAT=$2 ;;
|
||||
|
||||
* ) MESSAGE+="$(echo $1) " ;;
|
||||
esac
|
||||
shift $_S
|
||||
shift 1
|
||||
done
|
||||
|
||||
[ $FORMAT ] || FORMAT=pretty
|
||||
local STYLED_MESSAGE
|
||||
case $FORMAT in
|
||||
pretty )
|
||||
STYLED_MESSAGE="$(echo "$MESSAGE" | sed 's/%/%%/g')"
|
||||
STYLED_MESSAGE="$({
|
||||
printf "${COLOR}"
|
||||
while IFS='' read line
|
||||
do
|
||||
[[ $PREFIX =~ ^[[:space:]]\+$ ]] && printf '\n'
|
||||
MESSAGE="$(echo "$MESSAGE" | sed 's/%/%%/g')"
|
||||
|
||||
printf "${PREFIX} : $(echo "$line" | sed 's/^ \+//; s/ \+$//')"
|
||||
local STYLED_MESSAGE="$({
|
||||
printf "${COLOR}"
|
||||
while IFS='' read line
|
||||
do
|
||||
[[ $PREFIX =~ ^[[:space:]]\+$ ]] && printf '\n'
|
||||
|
||||
PREFIX=$(echo $PREFIX | sed 's/./ /g')
|
||||
done <<< $MESSAGE
|
||||
})"
|
||||
STYLED_MESSAGE="${COLOR}$(echo "$STYLED_MESSAGE" | sed 's/%/%%/g')${__COLOR_RESET}${LAST_LINE_END}"
|
||||
;;
|
||||
json )
|
||||
STYLED_MESSAGE="$(
|
||||
echo '{}' | jq -c ".
|
||||
| .timestamp = \"$(date +%s)\"
|
||||
| .runtime = \"$SCWRYPTS_RUNTIME_ID\"
|
||||
| .status = \"$(echo "$PREFIX" | sed 's/ .*//')\"
|
||||
| .message = $(echo $MESSAGE | sed 's/^\t\+//' | jq -Rs)
|
||||
" | sed 's/\\/\\\\/g'
|
||||
)\n"
|
||||
;;
|
||||
* )
|
||||
echo "ERROR : unsupported format '$FORMAT'" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
printf "${PREFIX} : $(echo "$line" | sed 's/^ \+//; s/ \+$//')"
|
||||
|
||||
PREFIX=$(echo $PREFIX | sed 's/./ /g')
|
||||
done <<< $MESSAGE
|
||||
})"
|
||||
STYLED_MESSAGE="${COLOR}$(echo "$STYLED_MESSAGE" | sed 's/%/%%/g')${__COLOR_RESET}${LAST_LINE_END}"
|
||||
|
||||
|
||||
[[ $STDERR -eq 1 ]] && printf -- "$STYLED_MESSAGE" >&2
|
||||
[[ $STDOUT -eq 1 ]] && printf -- "$STYLED_MESSAGE"
|
||||
[[ $STDERR -eq 1 ]] && printf $STYLED_MESSAGE >&2
|
||||
[[ $STDOUT -eq 1 ]] && printf $STYLED_MESSAGE
|
||||
|
||||
return 0
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ CHECK_ENVIRONMENT() {
|
||||
$E "environment errors found (see above)\n$ERROR_MESSAGE"
|
||||
}
|
||||
|
||||
[[ $MISSING_ENVIRONMENT_VARIABLES -ne 0 ]] && [[ $__SCWRYPT ]] && {
|
||||
[[ $MISSING_ENVIRONMENT_VARIABLES -ne 0 ]] && {
|
||||
REMINDER "
|
||||
to quickly update missing environment variables, run:
|
||||
'scwrypts zsh/scwrypts/environment/edit'
|
||||
|
Loading…
Reference in New Issue
Block a user