From 6a3f354cb7420f0cf32762ef744ceaa9055bcf36 Mon Sep 17 00:00:00 2001 From: lew Date: Thu, 2 Apr 2026 18:51:08 +0100 Subject: [PATCH 01/10] feat: stop all and skip all with shared confirmation helper --- nag | 175 +++++++++++++++++++++++++++++++++++-------------- test/help.bats | 8 +-- test/skip.bats | 26 ++++++++ test/stop.bats | 24 +++++++ 4 files changed, 179 insertions(+), 54 deletions(-) diff --git a/nag b/nag index c11d701..ccc025c 100755 --- a/nag +++ b/nag @@ -211,23 +211,32 @@ _piped_input() { } # Usage: -# _confirm_action +# _confirm_action [] # # Prompts the user for confirmation before performing a bulk action on -# tagged alarms. Skipped when -f (force/_YES) is set. In non-interactive -# mode, prints a message asking the caller to pass -f. +# alarms. When is provided, the prompt includes the tag name. +# Skipped when -f (force/_YES) is set. In non-interactive mode, prints +# a message asking the caller to pass -f. # # Exit / Error Status: # 0 (success, true) If the action is confirmed. # 1 (error, false) If the action is denied or non-interactive without -f. _confirm_action() { - local _verb="${1}" _count="${2}" _tag="${3}" + local _verb="${1}" _count="${2}" _tag="${3:-}" (( _YES )) && return 0 + local _desc + if [[ -n "${_tag}" ]] + then + _desc="${_count} alarm(s) tagged [${_tag}]" + else + _desc="${_count} alarm(s)" + fi + if _interactive_input then - printf "%s %s alarm(s) tagged [%s]? [y/N] " "${_verb}" "${_count}" "${_tag}" + printf "%s %s? [y/N] " "${_verb}" "${_desc}" local _reply read -r _reply case "${_reply}" in @@ -235,7 +244,7 @@ _confirm_action() { *) return 1 ;; esac else - printf "%s %s alarm(s) tagged [%s]? Pass -f to confirm.\n" "${_verb}" "${_count}" "${_tag}" + printf "%s %s? Pass -f to confirm.\\n" "${_verb}" "${_desc}" return 1 fi } @@ -1222,8 +1231,8 @@ Usage: ${_ME} list all alarms ${_ME}