From b872adb7fe15a5e94083537f937dbbf48183db43 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Fri, 30 Nov 2018 16:56:15 +0100 Subject: [PATCH] Added colours to output level --- music-sync.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/music-sync.sh b/music-sync.sh index b3ed53d..d85b116 100755 --- a/music-sync.sh +++ b/music-sync.sh @@ -14,8 +14,8 @@ GetOptions() { ! getopt --test > /dev/null if [[ ${PIPESTATUS[0]} -ne 4 ]]; then VerboseOutput 5 "\`getopt --test\` failed" - echo "Sorry, It seems that your shell is not supported" - echo "If you're using mac or another unix-like system, please install GNU getopt" + VerboseOutput 5 "Sorry, It seems that your shell is not supported" + VerboseOutput 5 "If you're using MacOS or another unix-like system, please install GNU getopt" exit 1 fi @@ -69,7 +69,7 @@ GetOptions() { break ;; *) - echo "Programming error" + VerboseOutput 5 "Programming error" return 3 ;; esac @@ -109,26 +109,26 @@ VerboseOutput() { if [[ $verbose -le $1 ]]; then case "$1" in 0) - level="Verbose" + level="\033[1;36mVerbose\033[0m" ;; 1) - level=" Debug " + level="\033[1;34m Debug \033[0m" ;; 2) - level=" Info " + level="\033[1;37m Info \033[0m" ;; 3) - level="Warning" + level="\033[1;33mWarning\033[0m" ;; 4) - level=" Error " + level="\033[1;31m Error \033[0m" ;; 5) - level=" Fatal " + level="\033[1;30m Fatal \033[0m" ;; esac - echo "[$level] $2" >&2 + echo -e "[$level] $2" >&2 fi } @@ -199,7 +199,7 @@ if [[ -f /tmp/music-sync-filelist ]]; then fi CreateFileList $source $dest "" if [[ ! -f /tmp/music-sync-filelist ]]; then - VerboseOutput "Info" "Nothing to do!" + VerboseOutput 2 "Nothing to do!" exit 0 fi ConvertFiles