From 24924908b12b3bd667866b90dd3164592c7b032f Mon Sep 17 00:00:00 2001 From: _cry64 Date: Wed, 21 Jan 2026 12:50:46 +1000 Subject: [PATCH] add perr-badval & throw-badval --- ceru/libceru.sh | 2 ++ ceru/subcmds/new/ssh-key | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ceru/libceru.sh b/ceru/libceru.sh index 90db4ba..f5070df 100755 --- a/ceru/libceru.sh +++ b/ceru/libceru.sh @@ -55,6 +55,7 @@ function perr-badflag { perr "unrecognised flag ${BOLD}${MAGENTA}'$1'${RESET} function perr-noflagval { perr "flag ${BOLD}${MAGENTA}'$1'${RESET} requires ${BOLD}${MAGENTA}${2}${RESET} argument(s), but only ${BOLD}${MAGENTA}${3}${RESET} were given"; } function perr-badarg { perr "unrecognised arg ${BOLD}${MAGENTA}'$1'${RESET}"; } function perr-noarg { perr "required argument ${BOLD}${MAGENTA}'$1'${RESET} is missing"; } +function perr-badval { perr "value ${MAGENTA}\"$1\"${WHITE} is not valid for flag ${CYAN}$2${RESET}"} # Failures function throw { echo -e "${@:2}" >&2; if [[ "$1" -ge 0 ]]; then exit "$1"; fi; } function throw-usage { throw "$1" "$(perr-usage 2>&1)"; } @@ -62,6 +63,7 @@ function throw-badflag { throw "$1" "$(perr-badflag "${@:2}" 2>&1)"; } function throw-noflagval { throw "$1" "$(perr-noflagval "${@:2}" 2>&1)"; } function throw-badarg { throw "$1" "$(perr-badarg "${@:2}" 2>&1)"; } function throw-noarg { throw "$1" "$(perr-noarg "${@:2}" 2>&1)"; } +function throw-badval { throw "$1" "$(perr-badval "$2" "$3" 2>&1)"; } # Parsing/Validation function required { [[ -n "$1" ]] || throw-noarg 1 "${@:2}"; } diff --git a/ceru/subcmds/new/ssh-key b/ceru/subcmds/new/ssh-key index 1ee9474..82260aa 100755 --- a/ceru/subcmds/new/ssh-key +++ b/ceru/subcmds/new/ssh-key @@ -92,7 +92,7 @@ case "$TYPE" in EXTRA="$EXTRA -b 4096" ;; *) - throw-badvalue 1 "$TYPE" '-t|--type' + throw-badval 1 "$TYPE" '-t|--type' ;; esac