From 8fb851ed2fb5e553a2e9c8d9fceda6265cf6a20c Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 3 Nov 2019 18:07:39 +0100 Subject: color --- src/printer.go | 26 +++++++++++++++----------- 1 file 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 -- cgit 1.4.1