From 41065933e4928850ac4f2dde2475a543db8e5328 Mon Sep 17 00:00:00 2001 From: Seppia Date: Sun, 3 Jun 2018 20:36:09 +0200 Subject: Colored WARNING/ERROR messages Warning and error messages now are colored by default. This commit also deletes a space in search keywords string. --- repofish | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'repofish') diff --git a/repofish b/repofish index 5ae3939..f97d139 100755 --- a/repofish +++ b/repofish @@ -17,7 +17,7 @@ add_packages() { cd ${SRC_PATH} git clone ${URL_PREFIX}$i.git else - echo 'WARNING: Package '"$i"' already present.' + echo -e '\033[1;33mWARNING:\033[m Package '"$i"' already present.' fi done } @@ -27,7 +27,7 @@ clone_package() { cd ${SRC_PATH} git clone $1 else - echo 'WARNING: Package already present.' + echo -e '\033[1;33mWARNING:\033[m Package already present.' fi } @@ -37,7 +37,7 @@ rm_packages() { if [ -d "${SRC_PATH}/$i" ]; then rm -rf ${SRC_PATH}/$i else - echo 'WARNING: Package '"$i"' not present.' + echo -e '\033[1;33mWARNING:\033[m Package '"$i"' not present.' fi done } @@ -46,7 +46,7 @@ check_package() { if [ -d "${SRC_PATH}/$1" ]; then ${EDITOR} ${SRC_PATH}/$1/PKGBUILD else - echo 'WARNING: Package '"$1"' not found.' + echo -e '\033[1;33mWARNING:\033[m Package '"$1"' not found.' fi } @@ -130,7 +130,7 @@ install_packages() { cd $(find ${SRC_PATH}/* -type d -prune -iname "*$i") makepkg -Csi else - echo 'WARNING: Package '"$i"' not found.' + echo -e '\033[1;33mWARNING:\033[m Package '"$i"' not found.' fi done } @@ -155,7 +155,7 @@ search_packages() { OUT_STR=$(jq -r '.results | .[] | [.Name, .Version], .Description' <<< ${CURL_JSN}) SEARCH_OUT=$(sed -e 's/\\//g' -e 's/\[/\\033\[1\;36m\[/g' -e 's/",/\\033\[1\;33m", \[\\033\[1\;32m/g' \ -e 's/\]/\\033\[1\;33m\]\\033\[1\;37m\]/g' <<< ${OUT_STR}) - echo -ne ' \033[1;34m:: \033[1;37mYou searched using the following keywords (matching package name and/or description): "' + echo -ne '\033[1;34m:: \033[1;37mYou searched using the following keywords (matching package name and/or description): "' echo -ne \\033\[1\;33m${key[@]}\\033\[1\;37m\" echo -e ${SEARCH_OUT} | sed -e 's/\[ /\n/g' -e 's/ *\] /\n\t/g' -e 's/", / /g' -e 's/"//g' | \ sed -E '/'"${LIST_INST::-1}"'[^-]/ s/$/ '"$(echo -e \\033\[1\;35m[ Installed ]\\033\[1\;37m)"'/' @@ -201,19 +201,19 @@ print_help() { if [ "$1" == 'help' ]; then if [ "$2" != '' ]; then - echo 'ERROR: too many arguments.' + echo -e '\033[1;31mERROR:\033[m too many arguments.' else print_help fi elif [ "${SRC_PATH}" == '' ];then set_variables elif [ ! -d "${SRC_PATH}" ]; then - echo 'ERROR: SRC_PATH variable set to invalid path.' + echo -e '\033[1;31mERROR:\033[m SRC_PATH variable set to invalid path.' elif [ "$1" == '' ]; then - echo 'WARNING: no command called.' + echo -e '\033[1;33mWARNING:\033[m no command called.' elif [ "$1" == 'add' ]; then if [ "$2" == '' ]; then - echo 'ERROR: missing argument.' + echo -e '\033[1;31mERROR:\033[m missing argument.' else N=2 while [ "${!N}" != '' ]; do @@ -224,15 +224,15 @@ elif [ "$1" == 'add' ]; then fi elif [ "$1" == 'clone' ]; then if [ "$3" != '' ]; then - echo 'ERROR: too many arguments.' + echo -e '\033[1;31mERROR:\033[m too many arguments.' elif [ "$2" == '' ]; then - echo 'ERROR: missing argument.' + echo -e '\033[1;31mERROR:\033[m missing argument.' else clone_package $2 fi elif [ "$1" == 'rm' ]; then if [ "$2" == '' ]; then - echo 'ERROR: missing argument.' + echo -e '\033[1;31mERROR:\033[m missing argument.' else N=2 while [ "${!N}" != '' ]; do @@ -243,25 +243,25 @@ elif [ "$1" == 'rm' ]; then fi elif [ "$1" == 'check' ]; then if [ "$3" != '' ]; then - echo 'ERROR: too many arguments.' + echo -e '\033[1;31mERROR:\033[m too many arguments.' elif [ "$2" == '' ]; then - echo 'ERROR: missing argument.' + echo -e '\033[1;31mERROR:\033[m missing argument.' else check_package $2 fi elif [ "$1" == 'list' ]; then if [ "$2" != '' ]; then - echo 'ERROR: too many arguments.' + echo -e '\033[1;31mERROR:\033[m too many arguments.' else list_packages fi elif [ "$1" == 'update-repo' ]; then if [ "${REPO_PATH}" == '' ];then - echo 'ERROR: REPO_PATH variable not set.' + echo -e '\033[1;31mERROR:\033[m REPO_PATH variable not set.' elif [ ! -d "${REPO_PATH}" ]; then - echo 'ERROR: REPO_PATH variable set to invalid path.' + echo -e '\033[1;31mERROR:\033[m REPO_PATH variable set to invalid path.' elif [ "${REPO_NAME}" == '' ];then - echo 'ERROR: REPO_NAME variable not set.' + echo -e '\033[1;31mERROR:\033[m REPO_NAME variable not set.' elif [ "$2" != '' ]; then N=2 while [ "${!N}" != '' ]; do @@ -307,7 +307,7 @@ elif [ "$1" == 'update' ]; then fi elif [ "$1" == 'install' ]; then if [ "$2" == '' ]; then - echo 'ERROR: missing argument.' + echo -e '\033[1;31mERROR:\033[m missing argument.' else N=2 while [ "${!N}" != '' ]; do @@ -329,7 +329,7 @@ elif [ "$1" == 'clean' ]; then fi elif [ "$1" == 'search' ]; then if [ "$2" == '' ]; then - echo 'ERROR: missing argument(s).' + echo -e '\033[1;31mERROR:\033[m missing argument(s).' else N=2 while [ "${!N}" != '' ]; do @@ -339,5 +339,5 @@ elif [ "$1" == 'search' ]; then search_packages keywords[@] fi else - echo 'ERROR: unrecocnized command.' + echo -e '\033[1;31mERROR:\033[m unrecocnized command.' fi -- cgit v1.2.3