v3.9.0
===================================================================== --- Changes ------------------------------ - scwrypts runner has new arguments -q/--quiet allows quiet-mode operation while still logging to logfiles -v/--verbose forces verbose mode --version longform required (-v is now for "verbose" mode) - scwrypts runner now auto-detects certain CLI usage, running in quiet, logged mode if pattern match successfully identifies a single scwrypt (or when using --name); use --verbose to override this behavior - 'k exec' no longer requires double '--' if a '--' comes after - old : k exec -it my-pod-0 -- -- /bin/sh + new : k exec -it my-pod-0 -- /bin/sh + still works : k -- exec -it my-pod-0 -- /bin/sh --- Bug Fixes ---------------------------- - fixed various plugins/kubectl auto-completion settings; arguments after '--' or profile number (e.g. 'k 1 get deployments') will now appropriately autocomplete in the indicated profile - helm template functions now work on related .tpl files as well (renders from chart root) - fixed some goofy UTF-8 icons in zsh/lib/utils/io --- New Features ------------------------- - (experimental) scwrypts zsh plugin for interactive command selection (like CTRL+SPACE), but allows you to build command arguments, providing help dialogue for the selected command --- New Scripts -------------------------- - zsh/misc/tally ) helps keep tally-counts of things; helpful when running long scripts "what iteration am I on"
This commit is contained in:
Binary file not shown.
@ -4,6 +4,7 @@ DEPENDENCIES+=(helm kubeval)
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use helm/validate
|
||||
use scwrypts
|
||||
|
||||
#####################################################################
|
||||
|
||||
|
@ -38,6 +38,8 @@ HELM__VALIDATE() {
|
||||
HELM_ARGS+=(--values $TEMPLATE_FILENAME)
|
||||
USE_CHART_ROOT=1
|
||||
}
|
||||
[[ $TEMPLATE_FILENAME =~ .tpl$ ]] \
|
||||
&& USE_CHART_ROOT=1
|
||||
|
||||
[[ $(dirname $TEMPLATE_FILENAME) =~ ^$CHART_ROOT$ ]] \
|
||||
&& USE_CHART_ROOT=1
|
||||
|
106
zsh/lib/misc/tally.module.zsh
Normal file
106
zsh/lib/misc/tally.module.zsh
Normal file
@ -0,0 +1,106 @@
|
||||
#####################################################################
|
||||
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
#####################################################################
|
||||
|
||||
TALLY_USE_REDIS=false # maybe someday
|
||||
TALLY_PATH="$SCWRYPTS_DATA_PATH/tally"
|
||||
|
||||
#####################################################################
|
||||
|
||||
TALLY() {
|
||||
local USAGE="
|
||||
usage: [...options...]
|
||||
|
||||
options:
|
||||
-c, --increment-count increment the tally by this much (default 1)
|
||||
-n, --tally-name name of tally system (default 'default')
|
||||
|
||||
-g, --get only output the current value
|
||||
-s, --set set the tally to a specific value
|
||||
-r, --reset set the tally back to zero
|
||||
|
||||
--raw only output the tally value
|
||||
|
||||
-h, --help print this dialogue and exit
|
||||
|
||||
Simple tally mark system; keep track of a count.
|
||||
"
|
||||
|
||||
local INCREMENT_COUNT=1
|
||||
local TALLY_NAME=default
|
||||
local RAW=false
|
||||
|
||||
local SET_VALUE=
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-c | --increment-count ) INCREMENT_COUNT=$2; shift 1 ;;
|
||||
-n | --tally-name ) TALLY_NAME=$2; shift 1 ;;
|
||||
|
||||
-g | --get ) INCREMENT_COUNT=0 ;;
|
||||
|
||||
-s | --set ) SET_VALUE=$2; shift 1 ;;
|
||||
-r | --reset ) SET_VALUE=0 ;;
|
||||
|
||||
--raw ) RAW=true ;;
|
||||
|
||||
-h | --help ) USAGE; return 0 ;;
|
||||
|
||||
* ) ERROR "unknown argument '$1'" ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
[ $TALLY_NAME ] && echo "$TALLY_NAME" | grep -qv '/' \
|
||||
|| ERROR "invalid tally name '$TALLY_NAME'"
|
||||
|
||||
local TALLY_FILENAME="$TALLY_PATH/$TALLY_NAME.txt"
|
||||
|
||||
CHECK_ERRORS --no-fail || return 1
|
||||
|
||||
##########################################
|
||||
|
||||
local NEW_VALUE CURRENT_VALUE=0
|
||||
[ $SET_VALUE ] && NEW_VALUE=$SET_VALUE || {
|
||||
[ -f "$TALLY_FILENAME" ] && {
|
||||
CURRENT_VALUE=$(cat "$TALLY_FILENAME" | tail -n1 | grep '^[0-9]\+')
|
||||
}
|
||||
|
||||
[ $CURRENT_VALUE ] || {
|
||||
ERROR "malformed tally file '$TALLY_FILENAME'; aborting"
|
||||
return 1
|
||||
}
|
||||
|
||||
NEW_VALUE=$(($CURRENT_VALUE + $INCREMENT_COUNT))
|
||||
}
|
||||
|
||||
##########################################
|
||||
|
||||
local TALLY_DIR="$(dirname "$TALLY_FILENAME")"
|
||||
|
||||
[ -d "$TALLY_DIR" ] || mkdir -p "$TALLY_DIR"
|
||||
[ -d "$TALLY_DIR" ] || {
|
||||
ERROR "unable to write to '$TALLY_DIR'; aborting"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "# autogenerated tally file; avoid direct modification\n$NEW_VALUE" > "$TALLY_FILENAME" || {
|
||||
ERROR "failed to write to '$TALLY_FILENAME': aborting"
|
||||
return 1
|
||||
}
|
||||
|
||||
##########################################
|
||||
|
||||
case $RAW in
|
||||
true ) printf "$NEW_VALUE" ;;
|
||||
false )
|
||||
case $TALLY_NAME in
|
||||
default ) INFO "current tally : $NEW_VALUE" ;;
|
||||
* ) INFO "$TALLY_NAME : $NEW_VALUE" ;;
|
||||
esac
|
||||
esac
|
||||
}
|
@ -43,11 +43,11 @@ SUCCESS() { PREFIX="SUCCESS ✔" COLOR=$__GREEN PRINT "$@"; }
|
||||
WARNING() { PREFIX="WARNING " COLOR=$__ORANGE PRINT "$@"; }
|
||||
STATUS() { PREFIX="STATUS " COLOR=$__BLUE PRINT "$@"; }
|
||||
REMINDER() { PREFIX="REMINDER " COLOR=$__PURPLE PRINT "$@"; }
|
||||
INFO() { PREFIX="INFO " COLOR=$__WHITE PRINT "$@"; }
|
||||
INFO() { PREFIX="INFO ℹ" COLOR=$__WHITE PRINT "$@"; }
|
||||
|
||||
PROMPT() {
|
||||
PREFIX="PROMPT " COLOR=$__CYAN PRINT "$@"
|
||||
PREFIX="USER " COLOR=$__CYAN PRINT '' --no-line-end
|
||||
PREFIX="USER ⌨" COLOR=$__CYAN PRINT '' --no-line-end
|
||||
}
|
||||
|
||||
FAIL() { ERROR "${@:2}"; exit $1; }
|
||||
|
17
zsh/misc/tally
Executable file
17
zsh/misc/tally
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/zsh
|
||||
#####################################################################
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use misc/tally
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
unset USAGE
|
||||
TALLY $@
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
MAIN $@
|
Reference in New Issue
Block a user