about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-11-03 18:07:39 +0100
committerEmile <hanemile@protonmail.com>2019-11-03 18:07:39 +0100
commit8fb851ed2fb5e553a2e9c8d9fceda6265cf6a20c (patch)
tree261a7cb200e1dc3a035c38f67834f31b460bbb41 /src
parent79244e7df141a416c803b4f7d15819228ec610c5 (diff)
color
Diffstat (limited to 'src')
-rw-r--r--src/printer.go26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/printer.go b/src/printer.go
index 5720897..f36dd99 100644
--- a/src/printer.go
+++ b/src/printer.go
@@ -89,30 +89,34 @@ func printResponses(channels channels) {
 			}
 		}
 
-		// color to display the status code in (either green or red)
-		var color string
+		// localColor to display the status code in (either green or red)
+		var localColor string
 
-		// set the prefix, postfix and color according to the hidden state
+		// set the prefix, postfix and localColor according to the hidden state
 		if hidden == true {
 			prefix = ""
 			postfix = "\033[K\r"
-			color = "red"
+			localColor = "red"
 		} else {
 			prefix = "\r\033[K"
 			postfix = "\n"
-			color = "green"
+			localColor = "green"
 		}
 
 		// statusCode string (with ansi escape codes)
 		var statusCode string
 
-		// color
-		if color == "red" {
-			statusCode = red(fmt.Sprintf("%d", response.StatusCode))
-		} else if color == "green" {
-			statusCode = green(fmt.Sprintf("%d", response.StatusCode))
+		// localColor
+		if color == true {
+			if localColor == "red" {
+				statusCode = red(fmt.Sprintf("%d", response.StatusCode))
+			} else if localColor == "green" {
+				statusCode = green(fmt.Sprintf("%d", response.StatusCode))
+			} else {
+				statusCode = cyan(fmt.Sprintf("%d", response.StatusCode))
+			}
 		} else {
-			statusCode = cyan(fmt.Sprintf("%d", response.StatusCode))
+			statusCode = fmt.Sprintf("%d", response.StatusCode)
 		}
 
 		// print the requests