From c849ae14357aefd2b6f26f19ad53fb93af3c5e6e Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 13 Dec 2018 16:49:43 +0100 Subject: [PATCH] Add step-levels and check_util function Signed-off-by: Knut Ahlers --- bin/script_framework.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/script_framework.sh b/bin/script_framework.sh index c319b36..4fd16f6 100644 --- a/bin/script_framework.sh +++ b/bin/script_framework.sh @@ -4,6 +4,10 @@ COLOR_CYAN="\033[0;36m" COLOR_YELLOW="\033[0;33m" COLOR_PLAIN="\033[0m" +function check_util() { + which ${1} >/dev/null 2>&1 || fail "Missing ${1} util" +} + function error() { echo -e "${COLOR_RED}$@${COLOR_PLAIN}" >&2 } @@ -22,7 +26,7 @@ function info() { } function step() { - info "[$(date +%H:%M:%S)] $@" + info "[$(date +%H:%M:%S)] $(printf "%${script_level:-0}s" '' | tr ' ' '+')$@" } function success() {