v2.5.0
===================================================================== --- New Scripts -------------------------- zsh ) vundle-vim helpers - vim/vundle/edit-build-actions - vim/vundle/install - vim/vundle/rebuild quick install-from-source scripts - git/package/install - git/package/build (install --only-build) - git/package/download (install --only-pull) - git/package/update (install --update) config sym-linker (for source-controlled .configs) - config/update (symlinks + terminfo) - config/symlinks (set all symlinks from settings) - config/settings (edit settings which aren't scwrypts env variables) - config/terminfo (load all terminfo from settings) --- Changes ------------------------------ - helper comments are now inserted in all env files - removed underscore prefix for standard AWS environment variables - added "opening" and "finished editing" comments to __EDIT util - added __USAGE to format $USAGE variable to std:err - added __ERROR_CHECK to exit if any __ERROR(s) were called
This commit is contained in:
@ -6,6 +6,7 @@ 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"
|
||||
LC_COLLATE=C sort -uo "$ENV_FILE" "$ENV_FILE"
|
||||
}
|
||||
|
@ -17,16 +17,14 @@ ENV_FILE=$(__GET_ENV_FILE $ENV_NAME)
|
||||
[ ! -f $ENV_FILE ] && {
|
||||
__STATUS "Creating '$ENV_NAME'..." \
|
||||
&& cp $__ENV_TEMPLATE $ENV_FILE \
|
||||
&& __SUCCESS 'created!' \
|
||||
&& __RUN_SCWRYPT zsh/scwrypts/environment/synchronize -- --no-prompt \
|
||||
&& __SUCCESS "created '$ENV_NAME'" \
|
||||
|| { __ERROR "failed to create '$ENV_FILE'"; exit 1; }
|
||||
}
|
||||
|
||||
__STATUS "opening '$ENV_NAME' for editing..."
|
||||
__EDIT $ENV_FILE
|
||||
sed -i "s/^[A-Z]/export &/; s/^[^#=]\\+$/&=/" $ENV_FILE
|
||||
LC_COLLATE=C sort -uo $ENV_FILE $ENV_FILE
|
||||
_SORT_ENV $ENV_FILE
|
||||
|
||||
__STATUS "finished editing; looking for new environment variables"
|
||||
while read line
|
||||
do
|
||||
ENV_VAR=$(echo "$line" | sed 's/=.*$//; s/^export //')
|
||||
|
@ -27,6 +27,7 @@ _SYNCHRONIZE() {
|
||||
_INSERT_NEW_VARIABLES
|
||||
_REMOVE_OLD_VARIABLES
|
||||
_SORT_AND_CASCADE
|
||||
_ADD_DESCRIPTIONS
|
||||
|
||||
__SUCCESS 'finished sync!'
|
||||
}
|
||||
@ -126,5 +127,27 @@ _CASCADE_ENVIRONMENT() {
|
||||
__SUCCESS "finished '$PARENT_NAME' propagation"
|
||||
}
|
||||
|
||||
_ADD_DESCRIPTIONS() {
|
||||
__STATUS 'updating descriptions'
|
||||
while read DESCRIPTION_LINE
|
||||
do
|
||||
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)"
|
||||
done
|
||||
done < <(sed -n '/^[^ ]\+ \+| /p' "$__ENV_TEMPLATE.descriptions")
|
||||
|
||||
while read ENV_VAR
|
||||
do
|
||||
for ENV_NAME in $(echo $ENVIRONMENTS)
|
||||
do
|
||||
sed -i "/^export $ENV_VAR=/a \ " "$(__GET_ENV_FILE $ENV_NAME)"
|
||||
sed -i "s/^ $//" "$(__GET_ENV_FILE $ENV_NAME)"
|
||||
done
|
||||
done < <(grep -B1 '^$' "$__ENV_TEMPLATE.descriptions" | grep '|' | awk '{print $1;}')
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
_SYNCHRONIZE $@
|
||||
|
Reference in New Issue
Block a user