Compare commits

..

5 Commits

Author SHA1 Message Date
1b4060dd1c v4.4.4
=====================================================================

- improved compatibility of scwrypts.plugin.zsh; no longer relies on
  user default fzf configuration

- added temporary downgrade of fakeroot to archlinux publish CI due
  to a confirmed bug in v1.35 and v1.36
2024-08-23 11:43:42 -06:00
6aba11d0be v4.4.3
=====================================================================

--- Bug Fixes ----------------------------

- fixed a(nother) bug which emerged from the latest version of github's
  actions/runner-images; zx is now forcibly managed by the runner, so
  install scripts must be skipped in CI
2024-05-14 12:36:44 -06:00
a945daeecc v4.4.2
=====================================================================

--- Bug Fixes ----------------------------

- fixed a bug which emerged from the latest version of github's
  actions/runner-images
2024-05-10 14:14:08 -06:00
2ef20860c4 v4.4.1
=====================================================================

--- Bug Fixes ----------------------------

- scwrypts now run when using --group and --type options without --name
- fixed spacing issues in scwrypts --help
- added missing = sign in config

--- New Features -------------------------

- zsh completion now loads with scwrypts.plugin.zsh (requires compdef)
2024-05-09 16:46:57 -06:00
3fe01a7263 v4.4.0
=====================================================================

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
2024-05-08 23:11:09 -06:00
9 changed files with 229 additions and 68 deletions

View File

@ -52,6 +52,13 @@ custom:
useradd -m ci useradd -m ci
echo "ci ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers echo "ci ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
temp-downgrade-fakeroot:
- &archlinux-temp-downgrade-fakeroot
run:
name: downgrade fakeroot to v1.34 (v1.35 and v1.36 are confirmed to break)
command: |
pacman -U --noconfirm https://archive.archlinux.org/packages/f/fakeroot/fakeroot-1.34-1-x86_64.pkg.tar.zst
clone-aur: clone-aur:
- &archlinux-clone-aur - &archlinux-clone-aur
archlinux-run: archlinux-run:
@ -84,6 +91,7 @@ jobs:
executor: archlinux executor: archlinux
steps: steps:
- *archlinux-prepare - *archlinux-prepare
- *archlinux-temp-downgrade-fakeroot
- *archlinux-clone-aur - *archlinux-clone-aur
- *archlinux-clone-scwrypts - *archlinux-clone-scwrypts
- archlinux-run: - archlinux-run:
@ -110,6 +118,7 @@ jobs:
executor: archlinux executor: archlinux
steps: steps:
- *archlinux-prepare - *archlinux-prepare
- *archlinux-temp-downgrade-fakeroot
- *archlinux-clone-aur - *archlinux-clone-aur
- archlinux-run: - archlinux-run:
_name: update PKGBUILD and .SRCINFO _name: update PKGBUILD and .SRCINFO

View File

@ -13,8 +13,8 @@ export DISCORD__DEFAULT_CHANNEL_ID=
export DISCORD__DEFAULT_USERNAME= export DISCORD__DEFAULT_USERNAME=
export DISCORD__DEFAULT_WEBHOOK= export DISCORD__DEFAULT_WEBHOOK=
export LINEAR__API_TOKEN= export LINEAR__API_TOKEN=
export MEDIA_SYNC__S3_BUCKET export MEDIA_SYNC__S3_BUCKET=
export MEDIA_SYNC__TARGETS export MEDIA_SYNC__TARGETS=
export REDIS_AUTH= export REDIS_AUTH=
export REDIS_HOST= export REDIS_HOST=
export REDIS_PORT= export REDIS_PORT=

View File

@ -23,17 +23,15 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
-y, --yes auto-accept all [yn] prompts through current scwrypt -y, --yes auto-accept all [yn] prompts through current scwrypt
-e, --env <env-name> set environment; overwrites SCWRYPTS_ENV -e, --env <env-name> set environment; overwrites SCWRYPTS_ENV
-n shorthand for "--log-level 0" -n shorthand for "--log-level 0"
-v, --log-level [0-4] set incremental scwrypts log level to one of the following: -v, --log-level <0-4> set incremental scwrypts log level to one of the following:
0 : only command output and critical failures; skips logfile 0 : only command output and critical failures; skips logfile
1 : include success / failure messages 1 : include success / failure messages
2 : include status update messages 2 : include status update messages
3 : (default) include warning messages 3 : (default) include warning messages
4 : include debug messages 4 : include debug messages
-o, --output specify output format; one of: -o, --output <format> specify output format; one of: pretty,json (default: pretty)
pretty (default)
json (experimental)
alternate commands alternate commands
-h, --help display this message and exit -h, --help display this message and exit
@ -173,12 +171,14 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
((SHIFT_COUNT+=1)) ((SHIFT_COUNT+=1))
[ $2 ] || { ERROR "missing value for argument $1"; break; } [ $2 ] || { ERROR "missing value for argument $1"; break; }
SEARCH_GROUP=$2 SEARCH_GROUP=$2
GROUP=$2
;; ;;
-t | --type ) -t | --type )
((SHIFT_COUNT+=1)) ((SHIFT_COUNT+=1))
[ $2 ] || { ERROR "missing value for argument $1"; break; } [ $2 ] || { ERROR "missing value for argument $1"; break; }
SEARCH_TYPE=$2 SEARCH_TYPE=$2
TYPE=$2
;; ;;
### runtime settings ##################### ### runtime settings #####################
@ -249,7 +249,6 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
echo $SCWRYPTS_AVAILABLE | head -n1 echo $SCWRYPTS_AVAILABLE | head -n1
echo $SCWRYPTS_AVAILABLE | grep ' [^/]*'$SEARCH_TYPE'[^/]* ' echo $SCWRYPTS_AVAILABLE | grep ' [^/]*'$SEARCH_TYPE'[^/]* '
} \ } \
| awk '{$2=""; print $0;}' \
| sed 's/ \+$/'$(printf $__COLOR_RESET)'/; s/ \+/^/g' \ | sed 's/ \+$/'$(printf $__COLOR_RESET)'/; s/ \+/^/g' \
| column -ts '^' | column -ts '^'
) )
@ -259,9 +258,8 @@ source "$(dirname $(readlink -f "$0"))/zsh/lib/import.driver.zsh" || exit 42
SCWRYPTS_AVAILABLE=$( SCWRYPTS_AVAILABLE=$(
{ {
echo $SCWRYPTS_AVAILABLE | head -n1 echo $SCWRYPTS_AVAILABLE | head -n1
echo $SCWRYPTS_AVAILABLE | grep "$SEARCH_GROUP"'[^/]*$' echo $SCWRYPTS_AVAILABLE | grep "$SEARCH_GROUP"'[^/ ]*$'
} \ } \
| awk '{$NF=""; print $0;}' \
| sed 's/ \+$/'$(printf $__COLOR_RESET)'/; s/ \+/^/g' \ | sed 's/ \+$/'$(printf $__COLOR_RESET)'/; s/ \+/^/g' \
| column -ts '^' | column -ts '^'
) )

View File

@ -1,3 +1,12 @@
#
# typically you do not need to reload this plugin in a single session;
# if for some reason you do, you can run the following command and
# source this file again
#
# unset __SCWRYPTS_PLUGIN_LOADED
#
[[ $__SCWRYPTS_PLUGIN_LOADED =~ true ]] && return 0
##################################################################### #####################################################################
: \ : \
@ -9,7 +18,7 @@
} }
__SCWRYPTS_PARSE() { __SCWRYPTS_PARSE() {
SCWRYPT_SELECTION=$(scwrypts --list | fzf --prompt 'select a script : ' --header-lines 1) SCWRYPT_SELECTION=$(scwrypts --list | fzf --ansi --prompt 'select a script : ' --header-lines 1)
LBUFFER= RBUFFER= LBUFFER= RBUFFER=
[ $SCWRYPT_SELECTION ] || return 1 [ $SCWRYPT_SELECTION ] || return 1
@ -22,59 +31,193 @@ __SCWRYPTS_PARSE() {
##################################################################### #####################################################################
SCWRYPTS__ZSH_PLUGIN() { [ $SCWRYPTS_SHORTCUT ] && {
local SCWRYPT_SELECTION NAME TYPE GROUP SCWRYPTS__ZSH_PLUGIN() {
__SCWRYPTS_PARSE || { zle accept-line; return 0; } local SCWRYPT_SELECTION NAME TYPE GROUP
__SCWRYPTS_PARSE || { zle accept-line; return 0; }
RBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP" RBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP"
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; }
echo $SCWRYPT_SELECTION >&2
scwrypts -n --name $NAME --group $GROUP --type $TYPE -- --help >&2 || {
zle accept-line zle accept-line
return 0
} }
echo
zle reset-prompt zle -N scwrypts SCWRYPTS__ZSH_PLUGIN
LBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP -- " bindkey $SCWRYPTS_SHORTCUT scwrypts
unset SCWRYPTS_SHORTCUT
} }
zle -N scwrypts-builder SCWRYPTS__ZSH_BUILDER_PLUGIN
bindkey $SCWRYPTS_BUILDER_SHORTCUT scwrypts-builder
unset SCWRYPTS_BUILDER_SHORTCUT
##################################################################### #####################################################################
SCWRYPTS__ZSH_PLUGIN_ENV() { [ $SCWRYPTS_BUILDER_SHORTCUT ] && {
local RESET='reset' SCWRYPTS__ZSH_BUILDER_PLUGIN() {
local SELECTED=$(\ local SCWRYPT_SELECTION NAME TYPE GROUP
{ [ $SCWRYPTS_ENV ] && echo $RESET; scwrypts --list-envs; } \ __SCWRYPTS_PARSE || { echo >&2; zle accept-line; return 0; }
| fzf --prompt 'select an environment : ' \ echo $SCWRYPT_SELECTION >&2
)
zle clear-command-line scwrypts -n --name $NAME --group $GROUP --type $TYPE -- --help >&2 || {
[ $SELECTED ] && { zle accept-line
[[ $SELECTED =~ ^$RESET$ ]] \ return 0
&& RBUFFER='unset SCWRYPTS_ENV' \ }
|| RBUFFER="export SCWRYPTS_ENV=$SELECTED" echo
zle reset-prompt
LBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP -- "
} }
zle accept-line
zle -N scwrypts-builder SCWRYPTS__ZSH_BUILDER_PLUGIN
bindkey $SCWRYPTS_BUILDER_SHORTCUT scwrypts-builder
unset SCWRYPTS_BUILDER_SHORTCUT
} }
zle -N scwrypts-setenv SCWRYPTS__ZSH_PLUGIN_ENV #####################################################################
bindkey $SCWRYPTS_ENV_SHORTCUT scwrypts-setenv
unset SCWRYPTS_ENV_SHORTCUT [ $SCWRYPTS_ENV_SHORTCUT ] && {
SCWRYPTS__ZSH_PLUGIN_ENV() {
local RESET='reset'
local SELECTED=$(\
{ [ $SCWRYPTS_ENV ] && echo $RESET; scwrypts --list-envs; } \
| fzf --prompt 'select an environment : ' \
)
zle clear-command-line
[ $SELECTED ] && {
[[ $SELECTED =~ ^$RESET$ ]] \
&& RBUFFER='unset SCWRYPTS_ENV' \
|| RBUFFER="export SCWRYPTS_ENV=$SELECTED"
}
zle accept-line
}
zle -N scwrypts-setenv SCWRYPTS__ZSH_PLUGIN_ENV
bindkey $SCWRYPTS_ENV_SHORTCUT scwrypts-setenv
unset SCWRYPTS_ENV_SHORTCUT
}
##################################################################### #####################################################################
# badass(/terrifying?) zsh autocompletion
command -v compdef &>/dev/null && {
_scwrypts() {
echo $words | grep -q "\s--\s" && _arguments && return 0
eval "_arguments $(
{
HELP=$(scwrypts --help 2>&1 | sed -n 's/^\s\+\(-.* .\)/\1/p' | sed 's/[[]/(/g; s/[]]/)/g')
echo $HELP \
| sed 's/^\(\(-[^-\s]\),*\s*\|\)\(\(--[-a-z0-9A-Z\]*\)\s\(<\([^>]*\)>\|\)\|\)\s\+\(.*\)/\2[\7]:\6:->\2/' \
| grep -v '^[[]' \
;
echo $HELP \
| sed 's/^\(\(-[^-\s]\),*\s*\|\)\(\(--[-a-z0-9A-Z\]*\)\s\(<\([^>]*\)>\|\)\|\)\s\+\(.*\)/\4[\7]:\6:->\4/' \
| grep -v '^[[]' \
;
echo ":pattern:->pattern"
echo ":pattern:->pattern"
echo ":pattern:->pattern"
echo ":pattern:->pattern"
echo ":pattern:->pattern"
} | sed 's/::->.*$//g' | sed "s/\\(^\\|$\\)/'/g" | tr '\n' ' '
)"
local _group=''
echo $words | grep -q ' -g [^\s]' \
&& _group=$(echo $words | sed 's/.*-g \([^ ]\+\)\s*.*/\1/')
echo $words | grep -q ' --group .' \
&& _group=$(echo $words | sed 's/.*--group \([^ ]\+\)\s*.*/\1/')
local _type=''
echo $words | grep -q ' -t [^\s]' \
&& _type=$(echo $words | sed 's/.*-t \([^ ]\+\)\s*.*/\1/')
echo $words | grep -q ' --type .' \
&& _type=$(echo $words | sed 's/.*--type \([^ ]\+\)\s*.*/\1/')
local _name=''
echo $words | grep -q ' -m [^\s]' \
&& _name=$(echo $words | sed 's/.*-m \([^ ]\+\)\s*.*/\1/')
echo $words | grep -q ' --name .' \
&& _name=$(echo $words | sed 's/.*--name \([^ ]\+\)\s*.*/\1/')
local _pattern _patterns=()
[ ! $_name ] \
&& _patterns=($(echo "${words[@]:1}" | sed 's/\s\+/\n/g' | grep -v '^-'))
_get_remaining_scwrypts() {
[ $_name ] || local _name='[^ ]\+'
[ $_type ] || local _type='[^ ]\+'
[ $_group ] || local _group='[^ ]\+'
local remaining=$(\
scwrypts --list \
| sed "1d; s,\x1B\[[0-9;]*[a-zA-Z],,g" \
| grep "^$_name\s" \
| grep "\s$_group$" \
| grep "\s$_type\s" \
)
for _pattern in ${_patterns[@]}
do
remaining=$(echo "$remaining" | grep "$_pattern")
done
echo "$remaining"
}
case $state in
( -m | --name )
compadd $(_get_remaining_scwrypts | awk '{print $1;}' | sort -u)
;;
( -t | --type )
compadd $(_get_remaining_scwrypts | awk '{print $2;}' | sort -u)
;;
( -g | --group )
[[ $_name$_type$_group =~ ^$ ]] \
&& compadd $(scwrypts --list-groups) \
|| compadd $(_get_remaining_scwrypts | awk '{print $3;}' | sort -u) \
;;
( -e | --env )
compadd $(scwrypts --list-envs)
;;
( -v | --log-level )
local _help="$(\
scwrypts --help 2>&1 \
| sed -n '/-v, --log-level/,/^$/p' \
| sed -n 's/\s\+\([0-9]\) : \(.*\)/\1 -- \2/p' \
)"
eval "local _descriptions=($(echo "$_help" | sed "s/\\(^\|$\\)/'/g"))"
local _values=($(echo "$_help" | sed 's/ --.*//'))
compadd -d _descriptions -a _values
;;
( -o | --output )
compadd pretty json
;;
( pattern )
[[ $_name =~ ^$ ]] && {
local _remaining_scwrypts="$(_get_remaining_scwrypts)"
# stop providing suggestions if your pattern is sufficient
[[ $(echo $_remaining_scwrypts | wc -l) -le 1 ]] && return 0
local _remaining_patterns="$(echo "$_remaining_scwrypts" | sed 's/\s\+/\n/g; s|/|\n|g;' | sort -u)"
for _pattern in ${_patterns[@]}
do
_remaining_patterns="$(echo "$_remaining_patterns" | grep -v "^$_pattern$")"
done
compadd $(echo $_remaining_patterns)
}
;;
( * ) ;;
esac
}
compdef _scwrypts scwrypts
}
__SCWRYPTS_PLUGIN_LOADED=true

View File

@ -25,7 +25,7 @@ export SCWRYPTS_ROOT__scwrypts="$SCWRYPTS_ROOT"
##################################################################### #####################################################################
DEFAULT_CONFIG="$SCWRYPTS_ROOT/zsh/lib/config.user.zsh" DEFAULT_CONFIG="$SCWRYPTS_ROOT__scwrypts/zsh/lib/config.user.zsh"
source "$DEFAULT_CONFIG" source "$DEFAULT_CONFIG"
USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh" USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh"
@ -56,7 +56,6 @@ export \
source "$SCWRYPTS_ROOT/scwrypts.scwrypts.zsh" \ source "$SCWRYPTS_ROOT/scwrypts.scwrypts.zsh" \
|| FAIL 69 'failed to set up scwrypts group; aborting' || FAIL 69 'failed to set up scwrypts group; aborting'
SCWRYPTS_GROUPS=(scwrypts $(echo $SCWRYPTS_GROUPS | sed 's/\s\+/\n/g' | sort -u | grep -v '^scwrypts$'))
##################################################################### #####################################################################
@ -88,5 +87,9 @@ done
done done
} }
#####################################################################
SCWRYPTS_GROUPS=(scwrypts $(echo $SCWRYPTS_GROUPS | sed 's/\s\+/\n/g' | sort -u | grep -v '^scwrypts$'))
##################################################################### #####################################################################
__SCWRYPT=1 # arbitrary; indicates currently inside a scwrypt __SCWRYPT=1 # arbitrary; indicates currently inside a scwrypt

View File

@ -12,7 +12,10 @@ SCWRYPTS__RUN() { # context wrapper to run scwrypts within scwrypts
local EXIT_CODE=0 local EXIT_CODE=0
((SUBSCWRYPT+=1)) ((SUBSCWRYPT+=1))
SUBSCWRYPT=$SUBSCWRYPT $SCWRYPTS_ROOT/scwrypts $@ SCWRYPTS_LOG_LEVEL=$SCWRYPTS_LOG_LEVEL \
SUBSCWRYPT=$SUBSCWRYPT \
$SCWRYPTS_ROOT__scwrypts/scwrypts $@
EXIT_CODE=$? EXIT_CODE=$?
((SUBSCWRYPT-=1)) ((SUBSCWRYPT-=1))

View File

@ -12,7 +12,7 @@ SCWRYPTS__GET_AVAILABLE_SCWRYPTS() {
local GROUP GROUP_PATH GROUP_COLOR LOOKUP_PIDS=() local GROUP GROUP_PATH GROUP_COLOR LOOKUP_PIDS=()
{ {
echo 'NAME^TYPE^GROUP' echo 'NAME^TYPE^GROUP'
for GROUP in ${SCWRYPTS_GROUPS} for GROUP in ${SCWRYPTS_GROUPS[@]}
do do
GROUP_PATH=$(eval echo '$SCWRYPTS_ROOT__'$GROUP) GROUP_PATH=$(eval echo '$SCWRYPTS_ROOT__'$GROUP)
GROUP_COLOR=$(eval echo '$SCWRYPTS_COLOR__'$GROUP) GROUP_COLOR=$(eval echo '$SCWRYPTS_COLOR__'$GROUP)
@ -94,7 +94,7 @@ SCWRYPTS__GET_RUNSTRING() {
} }
RUNSTRING="SCWRYPTS_ENV=$ENV_NAME; $RUNSTRING" RUNSTRING="SCWRYPTS_ENV=$ENV_NAME; $RUNSTRING"
RUNSTRING="source $SCWRYPTS_ROOT/zsh/lib/import.driver.zsh; $RUNSTRING" RUNSTRING="source $SCWRYPTS_ROOT__scwrypts/zsh/lib/import.driver.zsh; $RUNSTRING"
local _VIRTUALENV=$(eval echo '$SCWRYPTS_VIRTUALENV_PATH__'$SCWRYPT_GROUP'/$SCWRYPT_TYPE/bin/activate') local _VIRTUALENV=$(eval echo '$SCWRYPTS_VIRTUALENV_PATH__'$SCWRYPT_GROUP'/$SCWRYPT_TYPE/bin/activate')
[ -f $_VIRTUALENV ] && RUNSTRING="source $_VIRTUALENV; $RUNSTRING" [ -f $_VIRTUALENV ] && RUNSTRING="source $_VIRTUALENV; $RUNSTRING"

View File

@ -124,7 +124,7 @@ UPDATE_VIRTUALENV__scwrypts__py() {
PIP_INSTALL_ARGS+=(--no-cache-dir) PIP_INSTALL_ARGS+=(--no-cache-dir)
PIP_INSTALL_ARGS+=(-r requirements.txt) PIP_INSTALL_ARGS+=(-r requirements.txt)
cd "$SCWRYPTS_ROOT/py" cd "$SCWRYPTS_ROOT__scwrypts/py"
pip install ${PIP_INSTALL_ARGS[@]} pip install ${PIP_INSTALL_ARGS[@]}
} }
@ -161,7 +161,9 @@ ACTIVATE_VIRTUALENV__scwrypts__zx() {
UPDATE_VIRTUALENV__scwrypts__zx() { UPDATE_VIRTUALENV__scwrypts__zx() {
local NPM_INSTALL_ARGS=() local NPM_INSTALL_ARGS=()
cd "$SCWRYPTS_ROOT/zx" [ $CI ] && NPM_INSTALL_ARGS+=(--ignore-scripts)
cd "$SCWRYPTS_ROOT__scwrypts/zx"
npm install ${NPM_INSTALL_ARGS[@]} npm install ${NPM_INSTALL_ARGS[@]}
} }

View File

@ -1,5 +1,8 @@
FZF() { FZF() {
[ $CI ] && FAIL 1 'currently in CI, but FZF requires user input' [ $CI ] && {
DEBUG "invoked FZF with $@"
FAIL 1 'currently in CI, but FZF requires user input'
}
local FZF_ARGS=() local FZF_ARGS=()