confz

git mirror of https://ccx.te2000.cz/bzr/confz
git clone https://ccx.te2000.cz/git/confz
Log | Files | Refs

commit e66e1669ea1dd3a71ab9330adb28b7b03d75c807
parent 2d27b577db8d0b5924d1c0f6c87571a71d675df8
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Fri, 15 Jan 2021 19:03:40 +0100

implement quiet mode
Diffstat:
Mbin/confz | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/bin/confz b/bin/confz @@ -8,10 +8,11 @@ zmodload zsh/zutil typeset -gA vars vars_prev typeset -ga do_command actions_performed -typeset -g confz_indent check_only verbose fail_reason +typeset -g confz_indent check_only verbose fail_reason quiet : ${check_only:=0} : ${verbose:=0} +: ${quiet:=0} # helper that prints out error message and exits die() { @@ -37,13 +38,13 @@ zparseopts -D - f+:=confz_opt_f || die "Unable to parse options" # trace-printing helpers confz_check_start() { - print -r - "${confz_indent}checking $fg_bold[default]$1$reset_color ${(@q)argv[2,-1]} ${reset_color}[" >&2 + (($quiet)) || print -r - "${confz_indent}checking $fg_bold[default]$1$reset_color ${(@q)argv[2,-1]} ${reset_color}[" >&2 confz_indent+=" " } confz_check_ok() { confz_indent=${confz_indent% } - print -r - "$confz_indent] $fg[green]$1$reset_color OK" >&2 + (($quiet)) || print -r - "$confz_indent] $fg[green]$1$reset_color OK" >&2 } confz_check_fail() { @@ -51,12 +52,12 @@ confz_check_fail() { if (($check_only)); then print -P "$confz_indent] $fg[red]$1$reset_color FAIL" >&2 else - print -P "$confz_indent] $fg[yellow]$1$reset_color NEED" >&2 + (($quiet)) || print -P "$confz_indent] $fg[yellow]$1$reset_color NEED" >&2 fi } confz_do() { - print -r - "$confz_indent$fg[yellow]*$fg[default] ${(q)@}" >&2 + (($quiet)) || print -r - "$confz_indent$fg[yellow]*$fg[default] ${(q)@}" >&2 actions_performed+=( "$*" ) "$@" || die "command failed with error $?: ${(q)@}" }