=====================================================================

--- Bug fixes ----------------------------

- s3/media-sync/push now pushes (instead of pull -- oops!)
- fixed a typo in the launch-or-show help
- environment actions no longer overwrite overwrite symlinks
This commit is contained in:
Wryn (yage) Wagner 2022-09-30 20:23:37 -06:00
parent 73e26a2ecb
commit a1256bb0af
7 changed files with 25 additions and 21 deletions

View File

@ -24,7 +24,7 @@ __SYNC_MEDIA() {
local FLAGS=(${@:3})
__STATUS "${ACTION}ing $2"
_AWS s3 sync $REMOTE_TARGET $LOCAL_TARGET $FLAGS \
_AWS s3 sync $A $B $FLAGS \
&& __SUCCESS "$2 up-to-date" \
|| { __ERROR "unable to sync $2 (see above)"; return 1; }
}

View File

@ -9,6 +9,7 @@ source ${0:a:h}/common.zsh
#####################################################################
LAUNCH_OR_SHOW() {
__INFO $@
local USAGE="
usage: <path-executable> [client-class] [...options...]
@ -30,7 +31,7 @@ LAUNCH_OR_SHOW() {
Depending on state, performs one of three useful functions
1) starts application
2) adds application window to the scratchpad
3) pulls applciation from scratchpad to foreground on active screen
3) pulls application from scratchpad to foreground on active screen
"
local APPLICATION CLIENT_CLASS

View File

@ -6,7 +6,9 @@ source ${0:a:h}/../common.zsh
_SORT_ENV() {
local ENV_FILE="$1"
sed -i "/^# /d; /^$/d" "$ENV_FILE"
sed -i "s/^[A-Z]/export &/; s/^[^#=]\\+$/&=/" "$ENV_FILE"
_SED -i "/^# /d; /^$/d" "$ENV_FILE"
_SED -i "s/^[A-Z]/export &/; s/^[^#=]\\+$/&=/" "$ENV_FILE"
LC_COLLATE=C sort -uo "$ENV_FILE" "$ENV_FILE"
}
_SED() { sed --follow-symlinks $@; }

View File

@ -25,7 +25,7 @@ cp "$TEMPLATE_ENV_FILE" "$ENV_FILE" \
|| __FAIL 3 "unable to create '$ENV_NAME'"
__STATUS 'stripping inherited values'
sed -i 's/ # inherited from.*$//' "$ENV_FILE" 2>/dev/null
_SED -i 's/ # inherited from.*$//' "$ENV_FILE" 2>/dev/null
__RUN_SCWRYPT zsh/scwrypts/environment/synchronize -- --no-prompt \
|| __FAIL 4 'failed to run environment sync'

View File

@ -27,7 +27,7 @@ _SORT_ENV $ENV_FILE
while read line
do
ENV_VAR=$(echo "$line" | sed 's/=.*$//; s/^export //')
ENV_VAR=$(echo "$line" | _SED 's/=.*$//; s/^export //')
grep -q "$ENV_VAR" $__ENV_TEMPLATE || {
((NEW_VAR+=1))
echo "export $ENV_VAR=" >> $__ENV_TEMPLATE

View File

@ -20,7 +20,7 @@ _SYNCHRONIZE() {
}
_SORT_ENV "$__ENV_TEMPLATE"
sed -i '/__[a-z_]\+=$/d' "$__ENV_TEMPLATE"
_SED -i '/__[a-z_]\+=$/d' "$__ENV_TEMPLATE"
git add $__ENV_TEMPLATE >/dev/null 2>&1
ENVIRONMENTS=$(__GET_ENV_NAMES | sort -r)
@ -40,7 +40,7 @@ _CLEAR_INHERITED_VARIABLES() {
for ENV_NAME in $(echo $ENVIRONMENTS)
do
ENV_FILE=$(__GET_ENV_FILE $ENV_NAME)
sed -i 's/ # inherited from.*//' "$ENV_FILE"
_SED -i 's/ # inherited from.*//' "$ENV_FILE"
done
}
@ -57,7 +57,7 @@ _INSERT_NEW_VARIABLES() {
echo $line >> $ENV_FILE && __STATUS "added '$line' to '$ENV_NAME'"
}
done
done < <(sed -n '/^./p' "$__ENV_TEMPLATE")
done < <(_SED -n '/^./p' "$__ENV_TEMPLATE")
}
_REMOVE_OLD_VARIABLES() {
@ -69,11 +69,11 @@ _REMOVE_OLD_VARIABLES() {
ENV_FILE=$(__GET_ENV_FILE $ENV_NAME)
while read line
do
ENV_VAR=$(echo "$line" | sed 's/=.*/=/')
ENV_VAR=$(echo "$line" | _SED 's/=.*/=/')
echo $ENV_VAR | grep -q '__[a-z_]\+=' && continue
grep -q "$ENV_VAR" "$__ENV_TEMPLATE" || {
sed -i "\\%$ENV_VAR%d" "$ENV_FILE"
_SED -i "\\%$ENV_VAR%d" "$ENV_FILE"
echo "$ENV_VAR" | grep -qv '^#' \
&& __WARNING "removed unwanted '$ENV_VAR' from '$ENV_NAME'"
}
@ -114,8 +114,8 @@ _CASCADE_ENVIRONMENT() {
while read PARENT_VAR
do
VAR_PATTERN=$(echo "$PARENT_VAR" | sed 's/=.*/=/; s/\//\/\//g')
__STATUS "propagating '$(echo $VAR_PATTERN | sed 's/^export \([^=]*\)=/\1/')' to children"
VAR_PATTERN=$(echo "$PARENT_VAR" | _SED 's/=.*/=/; s/\//\/\//g')
__STATUS "propagating '$(echo $VAR_PATTERN | _SED 's/^export \([^=]*\)=/\1/')' to children"
PARENT_VAR+=" # inherited from $PARENT_NAME"
@ -123,10 +123,10 @@ _CASCADE_ENVIRONMENT() {
do
CHILD_FILE=$(__GET_ENV_FILE $CHILD_NAME)
sed -i "/^$VAR_PATTERN/d" "$CHILD_FILE"
_SED -i "/^$VAR_PATTERN/d" "$CHILD_FILE"
echo $PARENT_VAR >> "$CHILD_FILE"
done
done < <(sed -n '/^[^#][^=]*=[^#]\+$/p' "$PARENT_FILE")
done < <(_SED -n '/^[^#][^=]*=[^#]\+$/p' "$PARENT_FILE")
__SUCCESS "finished '$PARENT_NAME' propagation"
}
@ -135,18 +135,18 @@ _ADD_DESCRIPTIONS() {
__STATUS 'updating descriptions'
while read DESCRIPTION_LINE
do
ENV_VAR=$(echo $DESCRIPTION_LINE | sed 's/ \+| .*$//')
DESCRIPTION=$(echo $DESCRIPTION_LINE | sed 's/^.* | //')
ENV_VAR=$(echo $DESCRIPTION_LINE | _SED 's/ \+| .*$//')
DESCRIPTION=$(echo $DESCRIPTION_LINE | _SED 's/^.* | //')
for ENV_NAME in $(echo $ENVIRONMENTS)
do
sed -i "/^export $ENV_VAR=/i # $DESCRIPTION" "$(__GET_ENV_FILE $ENV_NAME)"
_SED -i "/^export $ENV_VAR=/i # $DESCRIPTION" "$(__GET_ENV_FILE $ENV_NAME)"
done
done < <(sed -n '/^[^ ]\+ \+| /p' "$__ENV_TEMPLATE.descriptions")
done < <(_SED -n '/^[^ ]\+ \+| /p' "$__ENV_TEMPLATE.descriptions")
for ENV_NAME in $(echo $ENVIRONMENTS)
do
sed -i "/^# /i \ " "$(__GET_ENV_FILE $ENV_NAME)"
sed -i "s/^ $//" "$(__GET_ENV_FILE $ENV_NAME)"
_SED -i "/^# /i \ " "$(__GET_ENV_FILE $ENV_NAME)"
_SED -i "s/^ $//" "$(__GET_ENV_FILE $ENV_NAME)"
done
}

View File

@ -8,6 +8,7 @@ __PRINT() {
printf "${COLOR}${MESSAGE}${__COLOR_RESET}${LINE_END}"
}
[ ! $ERRORS ] && export ERRORS=0
__ERROR() { __PRINT $__RED "ERROR ✖ : $@" >&2; ((ERRORS+=1)); }
__SUCCESS() { __PRINT $__GREEN "SUCCESS ✔ : $@" >&2; }
__WARNING() { __PRINT $__ORANGE "WARNING  : $@" >&2; }