diff --git a/bashlib.sh b/bashlib.sh index d2d03f2..b1c2f2e 100644 --- a/bashlib.sh +++ b/bashlib.sh @@ -5,15 +5,23 @@ NC='\033[0m' # No Color debug() { - if [ "$DEBUG" = true ]; then - echo -e "🐛 \033[0;36m[DEBUG]\033[0m $1" + if [[ -n "$DEBUG" ]]; then + local prompt=$1 + shift + local messasge=$* + + if [[ -n "$message" ]] ; then + message=": $message" + fi + + echo -e "🐛 \033[0;36m[DEBUG] ${prompt}\033[0m${message}" fi } error() { - prompt=$1 + local prompt=$1 shift - messasge=$* + local messasge=$* if [[ -n "$message" ]] ; then message=": $message" @@ -24,9 +32,9 @@ error() { } step() { - prompt=$1 + local prompt=$1 shift - messasge=$* + local messasge=$* if [[ -n "$message" ]] ; then message=": $message" @@ -36,9 +44,9 @@ step() { } success() { - prompt=$1 + local prompt=$1 shift - messasge=$* + local messasge=$* if [[ -n "$message" ]] ; then message=": $message" @@ -47,3 +55,11 @@ success() { echo -e "${GREEN}✅ ${prompt}${NC}${message}" } +check_command() { + local command=$1 + + if [[ -z $(which ${command}) ]] ; then + error "Missing command" ${command} + fi +} +