===================================================================== Excited to bring V5 to life. This includes some BREAKING CHANGES to several aspects of ZSH-type scwrypts. Please refer to the readme for upgrade details (specifically docs/upgrade/v4-to-v5.md) --- New Features ------------------------- - ZSH testing library with basic mock capabilities - new scwrypts environment file format includes metadata and more advanced features like optional parent env overrides, selection inheritence, and improved structurual flexibility - speedup cache for non-CI runs of ZSH-type scwrypts - ${scwryptsmodule} syntax now allows a consistent unique-naming scheme for functions in ZSH-type scwrypts while providing better insight into origin of API calls in other modules - reusable, case-statement-driven argument parsers in ZSH-type scwrypts --- Changes ------------------------------ - several utility function renames in ZSH-type scwrypts to improve consistency - documentation comments included in ZSH libraries - ZSH-type scwrypts now allow library modules to live alongside executables (zsh/lib still supported; autodetection determines default) --- Bug Fixes ---------------------------- - hardened environment checking for REQUIRED_ENV variables; this removes the ability to overwrite variables in local function contexts
48 lines
1.3 KiB
Bash
48 lines
1.3 KiB
Bash
#####################################################################
|
|
command -v compdef >/dev/null 2>&1 || return 0
|
|
#####################################################################
|
|
|
|
for CLI in kubectl helm flux
|
|
do
|
|
eval "_${CLI[1]}() {
|
|
local SUBSESSION=0
|
|
local SUBSESSION_OFFSET=2
|
|
echo \${words[2]} | grep -q '^[0-9]\\+$' && SUBSESSION=\${words[2]} && SUBSESSION_OFFSET=3
|
|
|
|
local PASSTHROUGH_WORDS=($CLI)
|
|
[[ \$CURRENT -gt \${SUBSESSION_OFFSET} ]] && echo \${words[\${SUBSESSION_OFFSET}]} | grep -qv '^[0-9]\\+$' && {
|
|
local KUBECONTEXT=\$(k \$SUBSESSION meta get context)
|
|
local NAMESPACE=\$(k \$SUBSESSION meta get namespace)
|
|
|
|
[ \$KUBECONTEXT ] \
|
|
&& PASSTHROUGH_WORDS+=($([[ $CLI =~ ^helm$ ]] && echo '--kube-context' || echo '--context') \$KUBECONTEXT) \
|
|
;
|
|
[ \$NAMESPACE ] \
|
|
&& PASSTHROUGH_WORDS+=(--namespace \$NAMESPACE) \
|
|
;
|
|
}
|
|
|
|
local DELIMIT_COUNT=0
|
|
local WORD
|
|
for WORD in \${words[@]:1}
|
|
do
|
|
case \$WORD in
|
|
( [0-9]* ) continue ;;
|
|
( -- )
|
|
echo \$words | grep -q 'exec' && ((DELIMIT_COUNT+=1))
|
|
[[ \$DELIMIT_COUNT -eq 0 ]] && ((DELIMIT_COUNT+=1)) && continue
|
|
;;
|
|
esac
|
|
PASSTHROUGH_WORDS+=(\"\$WORD\")
|
|
done
|
|
|
|
echo \"\$words\" | grep -q '\\s\\+$' && PASSTHROUGH_WORDS+=(' ')
|
|
|
|
words=\"\${PASSTHROUGH_WORDS[@]}\"
|
|
_$CLI
|
|
}
|
|
"
|
|
|
|
compdef _${CLI[1]} ${CLI[1]}
|
|
done
|