Add option to suppress success messages
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
26653a0e01
commit
4422f1f582
1 changed files with 17 additions and 0 deletions
17
bin/sanity
17
bin/sanity
|
@ -5,6 +5,21 @@ source ${HOME}/bin/script_framework.sh
|
||||||
|
|
||||||
reportpad=0
|
reportpad=0
|
||||||
retcode=0
|
retcode=0
|
||||||
|
showsuccess=1
|
||||||
|
|
||||||
|
while getopts "hq" opt; do
|
||||||
|
case "${opt}" in
|
||||||
|
q)
|
||||||
|
showsuccess=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $(basename $0) [-hq]"
|
||||||
|
echo " -h Show help"
|
||||||
|
echo " -q Quiet (show no success messages)"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# report is a wrapper to display messages in a certain level with
|
# report is a wrapper to display messages in a certain level with
|
||||||
# added information about the function yielding the result. It
|
# added information about the function yielding the result. It
|
||||||
|
@ -15,6 +30,8 @@ function report() {
|
||||||
local message="$@"
|
local message="$@"
|
||||||
local func="${FUNCNAME[1]#sanity_}"
|
local func="${FUNCNAME[1]#sanity_}"
|
||||||
|
|
||||||
|
[[ $levelfunc == "success" ]] && [ $showsuccess -eq 0 ] && return || true
|
||||||
|
|
||||||
"$levelfunc" "$(printf "%-${reportpad}s" ${func}) ${message}"
|
"$levelfunc" "$(printf "%-${reportpad}s" ${func}) ${message}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue