basic runner format; write a MAIN function

This commit is contained in:
Wryn (yage) Wagner 2024-02-06 14:06:44 -07:00
parent a200c1eb22
commit fcf492c661
50 changed files with 298 additions and 522 deletions

View File

@ -1,10 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/ecr
CHECK_ENVIRONMENT
#####################################################################
ECR_LOGIN $@
MAIN() {
ECR_LOGIN $@
}

View File

@ -3,11 +3,9 @@ DEPENDENCIES+=(jq)
REQUIRED_ENV+=(AWS__EFS__LOCAL_MOUNT_POINT)
use cloud/aws/cli
CHECK_ENVIRONMENT
#####################################################################
EFS_CONNECT() {
MAIN() {
GETSUDO || exit 1
[ ! -d $AWS__EFS__LOCAL_MOUNT_POINT ] && {
sudo mkdir $AWS__EFS__LOCAL_MOUNT_POINT \
@ -64,6 +62,3 @@ EFS_CONNECT() {
FAIL 2 "unable to mount '$FS_ID'"
}
}
#####################################################################
EFS_CONNECT $@

View File

@ -3,11 +3,9 @@ DEPENDENCIES+=(jq)
REQUIRED_ENV+=(AWS__EFS__LOCAL_MOUNT_POINT)
use cloud/aws/cli
CHECK_ENVIRONMENT
#####################################################################
EFS_DISCONNECT() {
MAIN() {
[ ! -d "$AWS__EFS__LOCAL_MOUNT_POINT" ] && {
STATUS 'no efs currently mounted'
exit 0
@ -32,6 +30,3 @@ EFS_DISCONNECT() {
&& SUCCESS "done" \
|| FAIL 2 "failed to unmount '$EFS'"
}
#####################################################################
EFS_DISCONNECT $@

View File

@ -1,10 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/eks
CHECK_ENVIRONMENT
#####################################################################
EKS__CLUSTER_LOGIN $@
MAIN() {
EKS__CLUSTER_LOGIN $@
}

View File

@ -1,19 +1,11 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/rds
use db/postgres
CHECK_ENVIRONMENT
#####################################################################
CREATE_BACKUP() {
MAIN() {
local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS
RDS__GET_DATABASE_CREDENTIALS $@ || return 1
PG_DUMP
}
#####################################################################
CREATE_BACKUP $@

View File

@ -1,20 +1,11 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/rds
use db/postgres
CHECK_ENVIRONMENT
#####################################################################
RDS_INTERACTIVE_LOGIN() {
MAIN() {
local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS
RDS__GET_DATABASE_CREDENTIALS $@ || return 1
POSTGRES__LOGIN_INTERACTIVE
}
#####################################################################
RDS_INTERACTIVE_LOGIN $@

View File

@ -1,20 +1,11 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/rds
use db/postgres
CHECK_ENVIRONMENT
#####################################################################
LOAD_BACKUP() {
MAIN() {
local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS
RDS__GET_DATABASE_CREDENTIALS $@ || return 1
PG_RESTORE
}
#####################################################################
LOAD_BACKUP $@

View File

@ -1,11 +1,9 @@
#!/bin/zsh
DEPENDENCIES+=(cli53)
REQUIRED_ENV+=(AWS_PROFILE)
CHECK_ENVIRONMENT
#####################################################################
ROUTE53_BACKUP() {
MAIN() {
local BACKUP_PATH="$SCWRYPTS_OUTPUT_PATH/$ENV_NAME/aws-dns-backup/$(date '+%Y-%m-%d')"
mkdir -p $BACKUP_PATH >/dev/null 2>&1
@ -25,12 +23,11 @@ ROUTE53_BACKUP() {
for P in ${JOBS[@]}; do wait $P >/dev/null 2>&1; done
}
#####################################################################
ROUTE53_GET_DOMAINS() {
cli53 list --profile $AWS_PROFILE \
| awk '{print $2;}' \
| sed '1d; s/\.$//'\
;
}
#####################################################################
ROUTE53_BACKUP

View File

@ -1,10 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/media-sync
CHECK_ENVIRONMENT
#####################################################################
MEDIA_SYNC__PULL $@
MAIN() {
MEDIA_SYNC__PULL $@
}

View File

@ -1,10 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/media-sync
CHECK_ENVIRONMENT
#####################################################################
MEDIA_SYNC__PUSH $@
MAIN() {
MEDIA_SYNC__PUSH $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use db/postgres
CHECK_ENVIRONMENT
#####################################################################
POSTGRES__LOGIN_INTERACTIVE $@
MAIN() {
POSTGRES__LOGIN_INTERACTIVE $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use db/postgres
CHECK_ENVIRONMENT
#####################################################################
PG_DUMP $@
MAIN() {
PG_DUMP $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use db/postgres
CHECK_ENVIRONMENT
#####################################################################
PG_RESTORE $@
MAIN() {
PG_RESTORE $@
}

View File

@ -1,13 +1,9 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use db/postgres
CHECK_ENVIRONMENT
#####################################################################
RUN_SQL_POSTGRES() {
MAIN() {
WARNING " \nthis function is in a beta state\n "
local _PASS _ARGS=()
POSTGRES__SET_LOGIN_ARGS $@
@ -43,9 +39,3 @@ RUN_SQL_POSTGRES() {
&& SUCCESS "finished running '$INPUT_FILE'" \
|| FAIL 3 "something went wrong running '$INPUT_FILE' (see above)"
}
#####################################################################
WARNING
WARNING 'this function is in a beta state'
WARNING
RUN_SQL_POSTGRES $@

View File

@ -1,11 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=(docker)
REQUIRED_ENV+=()
CHECK_ENVIRONMENT
#####################################################################
DOCKER_CLEAN() {
MAIN() {
WARNING 'this will prune all docker resources from the current machine'
WARNING 'pruned resources are PERMANENTLY DELETED'
yN 'continue?' || return 1
@ -14,6 +11,3 @@ DOCKER_CLEAN() {
SUCCESS "IMAGE : $(docker image prune -f 2>/dev/null | tail -n 1)"
SUCCESS "VOLUME : $(docker volume prune -f 2>/dev/null | tail -n 1)"
}
#####################################################################
DOCKER_CLEAN $@

View File

@ -1,8 +1,4 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
CHECK_ENVIRONMENT
#####################################################################
SUCCESS 'hello world!'
MAIN() {
SUCCESS 'hello world!'
}

View File

@ -1,17 +1,9 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use helm
use scwrypts
CHECK_ENVIRONMENT
#####################################################################
MAIN() {
unset USAGE
HELM__TEMPLATE__GET $@
}
#####################################################################
MAIN $@

View File

@ -1,17 +1,9 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use helm
use scwrypts
CHECK_ENVIRONMENT
#####################################################################
MAIN() {
unset USAGE
HELM__DEPENDENCY__UPDATE $@
}
#####################################################################
MAIN $@

View File

@ -112,11 +112,28 @@ SCWRYPTS__GET_RUNSTRING() {
SCWRYPTS__GET_RUNSTRING__zsh() {
__CHECK_DEPENDENCY zsh || return 1
local SCWRYPT_FILENAME
[ $(eval echo '$SCWRYPTS_TYPE__'$SCWRYPT_GROUP) ] \
&& SCWRYPT_FILENAME="$GROUP_PATH/$SCWRYPT_NAME" \
|| SCWRYPT_FILENAME="$GROUP_PATH/$SCWRYPT_TYPE/$SCWRYPT_NAME" \
;
echo "source '$SCWRYPT_FILENAME'; CHECK_ENVIRONMENT; MAIN"
return 0
}
SCWRYPTS__GET_RUNSTRING__zsh_v3_compatibility() {
__CHECK_DEPENDENCY zsh || return 1
[ $(eval echo '$SCWRYPTS_TYPE__'$SCWRYPT_GROUP) ] \
&& echo "source $GROUP_PATH/$SCWRYPT_NAME" \
|| echo "source $GROUP_PATH/$SCWRYPT_TYPE/$SCWRYPT_NAME" \
;
WARNING "scwrypts zsh/v3 runstrings are now deprecated; please update to scwrypts v4 format"
return 0
}

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use media/youtube
CHECK_ENVIRONMENT
#####################################################################
DOWNLOAD_VIDEO() {
MAIN() {
local URLS=($@)
[[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_HEAD 'enter URL'))
@ -23,6 +18,3 @@ DOWNLOAD_VIDEO() {
&& SUCCESS "downloaded to '$YT__OUTPUT_DIR/$FILENAME'" \
|| { ERROR "failed to download '$FILENAME'"; return 2; }
}
#####################################################################
DOWNLOAD_VIDEO $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use media/youtube
CHECK_ENVIRONMENT
#####################################################################
GET_AUDIO_CLIP() {
MAIN() {
local URLS=($@)
[[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_HEAD 'enter URL'))
@ -49,6 +44,3 @@ GET_AUDIO_CLIP() {
&& SUCCESS "created clip '$OUTPUT_FILE'" \
|| { ERROR "error creating clip '$(basename $OUTPUT_FILE)' (see above)"; return 3; }
}
#####################################################################
GET_AUDIO_CLIP $@

View File

@ -1,17 +1,8 @@
#!/bin/zsh
#####################################################################
DEPENDENCIES+=()
REQUIRED_ENV+=()
use misc/tally
CHECK_ENVIRONMENT
#####################################################################
MAIN() {
unset USAGE
TALLY $@
}
#####################################################################
MAIN $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex
CHECK_ENVIRONMENT
#####################################################################
PDFLATEX() {
MAIN() {
[ ! $1 ] && FAIL 1 'must provide filename'
local FILENAME=$(LATEX__GET_MAIN_FILENAME "$1")
@ -26,6 +21,3 @@ PDFLATEX() {
SUCCESS "created '$(echo $FILENAME | sed 's/\.[^.]*$/.pdf/')'"
}
#####################################################################
PDFLATEX $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex
CHECK_ENVIRONMENT
#####################################################################
CLEAN_LATEX_LOGFILES() {
MAIN() {
local DIRECTORY=$(SCWRYPTS__GET_REALPATH ".")
[ $1 ] && DIRECTORY="$(dirname "$(LATEX__GET_MAIN_FILENAME "$1")")"
[ $DIRECTORY ] && [ -d $DIRECTORY ] \
@ -18,6 +13,3 @@ CLEAN_LATEX_LOGFILES() {
SUCCESS "cleaned up latex artifacts in '$DIRECTORY'"
}
#####################################################################
CLEAN_LATEX_LOGFILES $@

View File

@ -1,15 +1,10 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex
CHECK_ENVIRONMENT
#####################################################################
TEMPLATE_DIR="${0:a:h}/templates"
CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE() {
MAIN() {
local DOCUMENT_DIR="$EXECUTION_DIR"
local TEMPLATE=$(GET_TEMPLATES | FZF 'select a template')
[ ! $TEMPLATE ] && ABORT
@ -39,6 +34,8 @@ CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE() {
SUCCESS "finished generating '$(basename $DOCUMENT_FILE)' from '$TEMPLATE'"
}
#####################################################################
GET_TEMPLATES() {
find "$TEMPLATE_DIR" -type d | sed "s^$TEMPLATE_DIR/*^^; /^$/d"
}
@ -59,4 +56,4 @@ SLUGIFY_TITLE() {
}
#####################################################################
CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE $@
MAIN $@

View File

@ -1,10 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex
CHECK_ENVIRONMENT
#####################################################################
LATEX__GET_PDF $@
MAIN() {
LATEX__GET_PDF $@
}

View File

@ -1,18 +1,10 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex
CHECK_ENVIRONMENT
#####################################################################
OPEN_PDF() {
MAIN() {
local PDF=$(LATEX__GET_PDF $@)
[ ! $PDF ] && return 1
OPEN "$PDF"
}
#####################################################################
OPEN_PDF $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/memo
CHECK_ENVIRONMENT
#####################################################################
OPEN_MEMO() {
MAIN() {
local MEMO_NAME=$(MEMO__LIST_ALL | FZF_TAIL 'select/create a memo')
[ ! "$MEMO_NAME" ] && ABORT
@ -26,6 +21,3 @@ OPEN_MEMO() {
EDIT "$MEMO_FILE"
}
#####################################################################
OPEN_MEMO $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/memo
CHECK_ENVIRONMENT
#####################################################################
DELETE_MEMO() {
MAIN() {
local MEMO_NAME=$(MEMO__LIST_ALL | FZF 'select a memo to delete')
local MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE"
[ "$MEMO_NAME" ] && [ -f "$MEMO_FILE" ] || ABORT
@ -28,6 +23,3 @@ DELETE_MEMO() {
|| FAIL 1 "failed to remove memo '$MEMO_NAME'" \
;
}
#####################################################################
DELETE_MEMO $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use redis
CHECK_ENVIRONMENT
#####################################################################
CURL_WITH_CACHE() {
MAIN() {
[ ! $TTL ] && TTL=10
[[ $(REDIS__ENABLED) -eq 0 ]] && {
@ -46,7 +41,6 @@ CURL_WITH_CACHE() {
echo $OUTPUT
}
GET_URL_KEY() { echo "scwrypts:curl:$1" | sed 's/\s\+/+/g'; }
#####################################################################
CURL_WITH_CACHE $@
GET_URL_KEY() { echo "scwrypts:curl:$1" | sed 's/\s\+/+/g'; }

View File

@ -1,36 +1,33 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta
CHECK_ENVIRONMENT
#####################################################################
USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh"
MAIN() {
local USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh"
[ ! -f "$USER_CONFIG_OVERRIDES" ] && {
STATUS 'first-time setup detected; creating local configuration override...'
cp "$DEFAULT_CONFIG" "$USER_CONFIG_OVERRIDES"
[ ! -f "$USER_CONFIG_OVERRIDES" ] && {
STATUS 'first-time setup detected; creating local configuration override...'
cp "$DEFAULT_CONFIG" "$USER_CONFIG_OVERRIDES"
EDIT $USER_CONFIG_OVERRIDES
EDIT $USER_CONFIG_OVERRIDES
STATUS 'attempting first-time build for virtual environments'
SCWRYPTS__RUN --name scwrypts/virtualenv/update-all --group scwrypts --type zsh \
&& SUCCESS 'finished updating virtualenvs' \
|| WARNING 'unable to create one or more virtualenv (see above)' \
;
STATUS 'attempting first-time build for virtual environments'
SCWRYPTS__RUN --name scwrypts/virtualenv/update-all --group scwrypts --type zsh \
&& SUCCESS 'finished updating virtualenvs' \
|| WARNING 'unable to create one or more virtualenv (see above)' \
;
REMINDER '
in the future, you can use the following scwrypt to update required virtual
environments (equivalent to "npm install" or "pip install -r requirements"):
REMINDER '
in the future, you can use the following scwrypt to update required virtual
environments (equivalent to "npm install" or "pip install -r requirements"):
scwrypts --name scwrypts/virtualenv/update-all --group scwrypts --type zsh
'
} || {
EDIT "$USER_CONFIG_OVERRIDES"
scwrypts --name scwrypts/virtualenv/update-all --group scwrypts --type zsh
'
} || {
EDIT "$USER_CONFIG_OVERRIDES"
}
SUCCESS 'saved new configuration'
REMINDER 'changes which affect the hot-key plugin will require a ZSHRC reload'
}
SUCCESS 'saved new configuration'
REMINDER 'changes which affect the hot-key plugin will require a ZSHRC reload'

View File

@ -1,38 +1,35 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/environment-files
CHECK_ENVIRONMENT
#####################################################################
PROMPT 'choose an environment to copy'
TEMPLATE_ENV_NAME=$(SCWRYPTS__SELECT_ENV)
[ ! $TEMPLATE_ENV_NAME ] && ABORT
MAIN() {
PROMPT 'choose an environment to copy'
TEMPLATE_ENV_NAME=$(SCWRYPTS__SELECT_ENV)
[ ! $TEMPLATE_ENV_NAME ] && ABORT
STATUS "selected '$TEMPLATE_ENV_NAME'"
STATUS "selected '$TEMPLATE_ENV_NAME'"
PROMPT 'enter new environment name'
ENV_NAME=$(echo '' | FZF_HEAD 'new environment')
[ ! $ENV_NAME ] && ABORT
SCWRYPTS__GET_ENV_NAMES | grep -q $ENV_NAME && FAIL 1 "'$ENV_NAME' already exists"
PROMPT 'enter new environment name'
ENV_NAME=$(echo '' | FZF_HEAD 'new environment')
[ ! $ENV_NAME ] && ABORT
SCWRYPTS__GET_ENV_NAMES | grep -q $ENV_NAME && FAIL 1 "'$ENV_NAME' already exists"
for GROUP in ${SCWRYPTS_GROUPS[@]}
do
TEMPLATE_ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $TEMPLATE_ENV_NAME $GROUP 2>/dev/null)
ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $ENV_NAME $GROUP 2>/dev/null)
for GROUP in ${SCWRYPTS_GROUPS[@]}
do
TEMPLATE_ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $TEMPLATE_ENV_NAME $GROUP 2>/dev/null)
ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $ENV_NAME $GROUP 2>/dev/null)
STATUS "creating environment '$ENV_NAME'"
cat "$TEMPLATE_ENV_FILE" \
| sed 's/ # from.*//' \
> "$ENV_FILE" \
&& SUCCESS "created '$ENV_FILE'" \
|| FAIL 2 "something went wrong creating '$ENV_FILE'"
done
STATUS "creating environment '$ENV_NAME'"
cat "$TEMPLATE_ENV_FILE" \
| sed 's/ # from.*//' \
> "$ENV_FILE" \
&& SUCCESS "created '$ENV_FILE'" \
|| FAIL 2 "something went wrong creating '$ENV_FILE'"
done
STATUS "synchronizing environments"
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
&& SUCCESS "finished copy environment '$TEMPLATE_ENV_NAME > $ENV_NAME'" \
|| FAIL 3 'error during synchronization of new environment (see above)' \
;
STATUS "synchronizing environments"
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
&& SUCCESS "finished copy environment '$TEMPLATE_ENV_NAME > $ENV_NAME'" \
|| FAIL 3 'error during synchronization of new environment (see above)' \
;
}

View File

@ -1,36 +1,33 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/environment-files
CHECK_ENVIRONMENT
#####################################################################
PROMPT 'choose an environment to delete'
ENV_NAME=$(SCWRYPTS__SELECT_ENV)
[ ! $ENV_NAME ] && ABORT
MAIN() {
PROMPT 'choose an environment to delete'
ENV_NAME=$(SCWRYPTS__SELECT_ENV)
[ ! $ENV_NAME ] && ABORT
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME))
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME))
STATUS "preparing to remove '$ENV_NAME'"
STATUS "preparing to remove '$ENV_NAME'"
WARNING "
the '$ENV_NAME' environment will be removed configured options
and stored credentials will be lost forever:
WARNING "
the '$ENV_NAME' environment will be removed configured options
and stored credentials will be lost forever:
$(echo $ENV_FILES | sed 's| /|\n - /|g; s/^/ - /')
"
$(echo $ENV_FILES | sed 's| /|\n - /|g; s/^/ - /')
"
yN 'continue?' || ABORT
yN 'continue?' || ABORT
STATUS "removing environment"
for ENV_FILE in ${ENV_FILES[@]}
do
rm "$ENV_FILE" \
&& SUCCESS "removed '$ENV_FILE'" \
|| ERROR "unable to remove '$ENV_FILE'; is it protected?" \
;
done
STATUS "removing environment"
for ENV_FILE in ${ENV_FILES[@]}
do
rm "$ENV_FILE" \
&& SUCCESS "removed '$ENV_FILE'" \
|| ERROR "unable to remove '$ENV_FILE'; is it protected?" \
;
done
CHECK_ERRORS -n || FAIL 2 "some errors ocurred when cleaning up $ENV_NAME"
CHECK_ERRORS -n || FAIL 2 "some errors ocurred when cleaning up $ENV_NAME"
}

View File

@ -1,45 +1,42 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/environment-files
CHECK_ENVIRONMENT
#####################################################################
[ $1 ] && ENV_NAME="$1"
MAIN() {
[ $1 ] && ENV_NAME="$1"
[ ! $1 ] && {
[ $SCWRYPTS_ENV ] \
&& ENV_NAME=$SCWRYPTS_ENV \
|| ENV_NAME=$(SCWRYPTS__SELECT_OR_CREATE_ENV)
}
[ ! $ENV_NAME ] && ABORT
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME 2>/dev/null))
for ENV_FILE in ${ENV_FILES[@]}
do
[ ! -f "$ENV_FILE" ] && {
STATUS "Creating '$ENV_FILE'..." \
&& mkdir -p "$(dirname "$ENV_FILE")" \
&& touch "$ENV_FILE" \
&& ((CREATED+=1)) \
&& SUCCESS "created '$ENV_NAME'" \
|| { ERROR "failed to create '$ENV_FILE'"; exit 1; }
[ ! $1 ] && {
[ $SCWRYPTS_ENV ] \
&& ENV_NAME=$SCWRYPTS_ENV \
|| ENV_NAME=$(SCWRYPTS__SELECT_OR_CREATE_ENV)
}
[ ! $ENV_NAME ] && ABORT
[ $CREATED ] && [[ $CREATED -gt 0 ]] && {
STATUS "detected new environment files; performing sync" \
&& SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|| FAIL 1 "failure during sync for '$ENV_NAME'" \
}
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME 2>/dev/null))
for ENV_FILE in ${ENV_FILES[@]}
do
[ ! -f "$ENV_FILE" ] && {
STATUS "Creating '$ENV_FILE'..." \
&& mkdir -p "$(dirname "$ENV_FILE")" \
&& touch "$ENV_FILE" \
&& ((CREATED+=1)) \
&& SUCCESS "created '$ENV_NAME'" \
|| { ERROR "failed to create '$ENV_FILE'"; exit 1; }
}
[ $CREATED ] && [[ $CREATED -gt 0 ]] && {
STATUS "detected new environment files; performing sync" \
&& SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|| FAIL 1 "failure during sync for '$ENV_NAME'" \
}
;
done
EDIT $ENV_FILES
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|| FAIL 4 'failed to run environment sync' \
;
done
EDIT $ENV_FILES
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|| FAIL 4 'failed to run environment sync' \
;
SUCCESS "environment '$ENV_NAME' successfully modified"
SUCCESS "environment '$ENV_NAME' successfully modified"
}

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/environment-files
CHECK_ENVIRONMENT
#####################################################################
SYNCHRONIZE() {
MAIN() {
while [[ $# -gt 0 ]]
do
case $1 in
@ -176,4 +171,4 @@ CLEANUP_ENVIRONMENT_FILE() {
}
#####################################################################
SYNCHRONIZE $@
MAIN $@

View File

@ -1,22 +1,20 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
CHECK_ENVIRONMENT
#####################################################################
cd $SCWRYPTS_ROOT
MAIN() {
cd $SCWRYPTS_ROOT
STATUS "Found $(ls $SCWRYPTS_LOG_PATH | wc -l) log files"
WARNING "
this will permanently clear all local cloud script logs found in
'$SCWRYPTS_LOG_PATH'
"
STATUS "Found $(ls $SCWRYPTS_LOG_PATH | wc -l) log files"
WARNING "
this will permanently clear all local cloud script logs found in
'$SCWRYPTS_LOG_PATH'
"
yN 'continue?' || ABORT
yN 'continue?' || ABORT
STATUS 'removing logfiles'
rm -rf $SCWRYPTS_LOG_PATH/* \
&& SUCCESS 'done' \
|| { ERROR 'failed :c'; exit 2; }\
;
STATUS 'removing logfiles'
rm -rf $SCWRYPTS_LOG_PATH/* \
&& SUCCESS 'done' \
|| { ERROR 'failed :c'; exit 2; }\
;
}

View File

@ -1,15 +1,13 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
CHECK_ENVIRONMENT
#####################################################################
cd $SCWRYPTS_ROOT
PROMPT 'select a script log'
LOG_FILE=$(ls -t $SCWRYPTS_LOG_PATH | FZF 'logfile')
[ ! $LOG_FILE ] && { ERROR 'user abort'; exit 1; }
MAIN() {
cd $SCWRYPTS_ROOT
PROMPT 'select a script log'
LOG_FILE=$(ls -t $SCWRYPTS_LOG_PATH | FZF 'logfile')
[ ! $LOG_FILE ] && { ERROR 'user abort'; exit 1; }
STATUS 'opening logfile'
LESS "$SCWRYPTS_LOG_PATH/$LOG_FILE"
SUCCESS 'done'
STATUS 'opening logfile'
LESS "$SCWRYPTS_LOG_PATH/$LOG_FILE"
SUCCESS 'done'
}

View File

@ -1,30 +1,27 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/virtualenv
CHECK_ENVIRONMENT
#####################################################################
while [[ $# -gt 0 ]]
do
case $1 in
-g | --group ) ENV_GROUP="$2"; shift 1 ;;
esac
shift 1
done
MAIN() {
while [[ $# -gt 0 ]]
do
case $1 in
-g | --group ) ENV_GROUP="$2"; shift 1 ;;
esac
shift 1
done
[ ! $ENV_GROUP ] && ENV_GROUP=scwrypts
[ ! $ENV_GROUP ] && ENV_GROUP=scwrypts
ENV_TYPE=$(echo $AVAILABLE_VIRTUALENVS | sed 's/ \+/\n/' | FZF 'select an environment to refresh')
[ ! $ENV_TYPE ] && ABORT
ENV_TYPE=$(echo $AVAILABLE_VIRTUALENVS | sed 's/ \+/\n/' | FZF 'select an environment to refresh')
[ ! $ENV_TYPE ] && ABORT
REMINDER "
this will permanently remove all artifacts for the scwrypts $ENV_TYPE environment
(safe unless you have put something important in $(GET_VIRTUALENV_PATH $ENV_GROUP $ENV_TYPE))
"
REMINDER "
this will permanently remove all artifacts for the scwrypts $ENV_TYPE environment
(safe unless you have put something important in $(GET_VIRTUALENV_PATH $ENV_GROUP $ENV_TYPE))
"
Yn "drop and recreate $ENV_TYPE virtual environment?" || ABORT
Yn "drop and recreate $ENV_TYPE virtual environment?" || ABORT
REFRESH_VIRTUALENV $ENV_GROUP $ENV_TYPE
REFRESH_VIRTUALENV $ENV_GROUP $ENV_TYPE
}

View File

@ -1,25 +1,21 @@
#!/bin/zsh
echo hey
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/virtualenv
CHECK_ENVIRONMENT
#####################################################################
STATUS 'beginning update for all environments'
MAIN() {
STATUS 'beginning update for all environments'
FAILED_COUNT=0
FAILED_COUNT=0
for ENV_GROUP in ${SCWRYPTS_GROUPS[@]}
do
for ENV_TYPE in ${AVAILABLE_VIRTUALENVS[@]}
for ENV_GROUP in ${SCWRYPTS_GROUPS[@]}
do
UPDATE_VIRTUALENV $ENV_GROUP $ENV_TYPE || ((FAILED_COUNT+=1))
for ENV_TYPE in ${AVAILABLE_VIRTUALENVS[@]}
do
UPDATE_VIRTUALENV $ENV_GROUP $ENV_TYPE || ((FAILED_COUNT+=1))
done
done
done
[[ $FAILED_COUNT -eq 0 ]] \
&& SUCCESS 'all environments up-to-date' \
|| FAIL $FAILED_COUNT "failed to update $FAILED_COUNT more environment(s)"
[[ $FAILED_COUNT -eq 0 ]] \
&& SUCCESS 'all environments up-to-date' \
|| FAIL $FAILED_COUNT "failed to update $FAILED_COUNT more environment(s)"
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/config
CHECK_ENVIRONMENT
#####################################################################
EDIT "$CONFIG__USER_SETTINGS"
MAIN() {
EDIT "$CONFIG__USER_SETTINGS"
}

View File

@ -1,19 +1,16 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/config
CHECK_ENVIRONMENT
#####################################################################
SETUP_SYMLINKS() {
MAIN() {
while read SYMLINK
do
SETUP_SYMLINK $(echo $SYMLINK | awk '{print $1;}') $(echo $SYMLINK | awk '{print $2}')
done < <(echo $SYMLINKS | sed -n '/^[^#]/p')
}
#####################################################################
SETUP_SYMLINK() {
[ ! $2 ] && FAIL 1 'must provide SOURCE_CONFIG and TARGET_CONFIG'
@ -42,6 +39,3 @@ SETUP_SYMLINK() {
|| FAIL 3 "failed to create link '$TARGET_CONFIG'" \
;
}
#####################################################################
SETUP_SYMLINKS $@

View File

@ -1,13 +1,10 @@
#!/bin/zsh
DEPENDENCIES+=(tic)
REQUIRED_ENV+=()
use system/config
CHECK_ENVIRONMENT
#####################################################################
SETUP_TERMINFO() {
MAIN() {
[ ! $TERMINFO_PATH ] && return 0
[ ! -d $TERMINFO_PATH ] && FAIL 1 "TERMINFO_PATH='$TERMINFO_PATH' does not exist"
@ -22,6 +19,3 @@ SETUP_TERMINFO() {
CHECK_ERRORS
}
#####################################################################
SETUP_TERMINFO $@

View File

@ -1,13 +1,10 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta
CHECK_ENVIRONMENT
#####################################################################
STATUS 'updating all config files and links'
SCWRYPTS__RUN --name system/config/symlinks --group scwrypts --type zsh || exit 1
SCWRYPTS__RUN --name system/config/terminfo --group scwrypts --type zsh || exit 2
SUCCESS 'finished updating config files and links'
MAIN() {
STATUS 'updating all config files and links'
SCWRYPTS__RUN --name system/config/symlinks --group scwrypts --type zsh || exit 1
SCWRYPTS__RUN --name system/config/terminfo --group scwrypts --type zsh || exit 2
SUCCESS 'finished updating config files and links'
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta
CHECK_ENVIRONMENT
#####################################################################
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-build $@
MAIN() {
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-build $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta
CHECK_ENVIRONMENT
#####################################################################
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-pull $@
MAIN() {
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-pull $@
}

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/packages/git
CHECK_ENVIRONMENT
#####################################################################
INSTALL() {
MAIN() {
local USAGE="
usage: [...options...]
@ -86,6 +81,3 @@ INSTALL() {
[[ $SKIP_BUILD -eq 1 ]] && return 0
BUILD
}
#####################################################################
INSTALL $@

View File

@ -1,9 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta
CHECK_ENVIRONMENT
#####################################################################
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --update $@
MAIN() {
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --update $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/vim/vundle
CHECK_ENVIRONMENT
#####################################################################
EDIT "$VUNDLE__BUILD_DEFINITIONS"
MAIN() {
EDIT "$VUNDLE__BUILD_DEFINITIONS"
}

View File

@ -1,13 +1,8 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/vim/vundle
CHECK_ENVIRONMENT
#####################################################################
PLUGIN_INSTALL() {
MAIN() {
[ -d "$HOME/.vim/bundle/Vundle.vim" ] || {
mkdir -p "$HOME/.vim/bundle/"
git clone https://github.com/VundleVim/Vundle.vim.git "$HOME/.vim/bundle/Vundle.vim"
@ -16,6 +11,3 @@ PLUGIN_INSTALL() {
VUNDLE__PLUGIN_INSTALL || return 1
VUNDLE__REBUILD_PLUGINS || return 2
}
#####################################################################
PLUGIN_INSTALL $@

View File

@ -1,9 +1,7 @@
#!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/vim/vundle
CHECK_ENVIRONMENT
#####################################################################
VUNDLE__REBUILD_PLUGINS $@
MAIN() {
VUNDLE__REBUILD_PLUGINS $@
}