Print warnings with the right color code

This commit is contained in:
Urjit Singh Bhatia
2020-05-04 16:33:50 -07:00
parent 5ac9be3292
commit 8cdf3838a0
2 changed files with 6 additions and 4 deletions

View File

@@ -47,7 +47,7 @@ else
# Colors
# NOTE: Your editor may NOT show the 0x1b / escape character left of the '['
NORMAL=""
WARNING="" # Bad (red)
WARNING="" # Warning (brown)
SECTION="" # Section (yellow)
NOTICE="" # Notice (yellow)
OK="" # Ok (green)
@@ -68,6 +68,6 @@ fi
printColorsCode(){
if [[ $MONOCHROME -eq 0 ]]; then
echo -e "\n$NORMAL Colors code for results: "
echo -e "$NOTICE INFO (Information)$NORMAL,$OK PASS (Recommended value)$NORMAL, $BAD WARNING (Ignored by whitelist)$NORMAL, $BAD FAIL (Fix required)$NORMAL, $PURPLE Not Scored $NORMAL"
echo -e "$NOTICE INFO (Information)$NORMAL,$OK PASS (Recommended value)$NORMAL, $WARNING WARNING (Ignored by whitelist)$NORMAL, $BAD FAIL (Fix required)$NORMAL, $PURPLE Not Scored $NORMAL"
fi
}

View File

@@ -86,6 +86,7 @@ textInfo(){
textFail(){
## ignore whitelists for current check
level="FAIL"
colorcode="$BAD"
for i in $IGNORES; do
ignore_check_name="${i%:*}"
ignore_value="${i#*${CHECK_NAME}:}"
@@ -95,6 +96,7 @@ textFail(){
fi
if [[ $1 =~ ${ignore_value} ]]; then
level="WARNING"
colorcode="$WARNING"
break
fi
done
@@ -128,10 +130,10 @@ textFail(){
output_junit_failure "$1"
fi
if [[ "${MODES[@]}" =~ "mono" ]]; then
echo " $BAD ${level}! $1 $NORMAL" | tee -a ${OUTPUT_FILE_NAME}.$EXTENSION_TEXT
echo " $colorcode ${level}! $1 $NORMAL" | tee -a ${OUTPUT_FILE_NAME}.$EXTENSION_TEXT
fi
if [[ "${MODES[@]}" =~ "text" ]]; then
echo " $BAD ${level}! $1 $NORMAL"
echo " $colorcode ${level}! $1 $NORMAL"
fi
}