Commit b95730e3 authored by dmknght's avatar dmknght

Add prntErr and prntWarn

parent ccdff244
Pipeline #1133 canceled with stages
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
{ {
"label": "[Test]Show user options", "label": "[Test]Show user options",
"type": "shell", "type": "shell",
"command": "nim c -r src/test/testargs.nim http://a.b -w x" "command": "nim c -r src/test/testargs.nim a.b -w x"
} }
] ]
} }
\ No newline at end of file
import terminal
proc showHelpCmd*(app = "dirbnim", keyword = "help", value = "", descr = "") = proc showHelpCmd*(app = "dirbnim", keyword = "help", value = "", descr = "") =
...@@ -16,6 +17,28 @@ proc showHelpCmd*(app = "dirbnim", keyword = "help", value = "", descr = "") = ...@@ -16,6 +17,28 @@ proc showHelpCmd*(app = "dirbnim", keyword = "help", value = "", descr = "") =
if value != "": if value != "":
cmdOutput &= "\e[33m" & value & "\e[0m " cmdOutput &= "\e[33m" & value & "\e[0m "
if descr != "": if descr != "":
cmdOutput &= "[\e[36m" & descr & "\e[0m]" cmdOutput &= "[\e[36m" & descr & "\e[0m]" # Cyan color
echo cmdOutput echo cmdOutput
proc progressBar*(subPath: string) =
stdout.eraseLine()
stdout.write(subPath)
stdout.flushFile()
proc prntErr*(reason: string, descr = "") =
var msg = "[\e[31mE\e[0m] " # Red
if descr != "":
msg &= "[\e[36m" & descr & "\e[0m] " # cyan
msg &= "\e[35m" & reason & "\e[0m"
echo msg
proc prntWarn*(reason: string, descr = "") =
var msg = "[\e[33mW\e[0m] " # Yellow
if descr != "":
msg &= "[\e[36m" & descr & "\e[0m] " # cyan
msg &= reason
echo msg
import strutils import strutils
import os import os
import .. / cli / utils
proc urlFormat*(url: string): string = proc urlFormat*(url: string): string =
...@@ -9,7 +10,7 @@ proc urlFormat*(url: string): string = ...@@ -9,7 +10,7 @@ proc urlFormat*(url: string): string =
Outpt: URL: string Outpt: URL: string
]# ]#
if not url.startsWith("http://") and not url.startsWith("https://"): if not url.startsWith("http://") and not url.startsWith("https://"):
echo "[W] Missing protocol in URL. Added http:// by default." prntWarn("Added http to url", "Missing protocol in URL")
result = "http://" & url result = "http://" & url
if not result.endsWith("/"): if not result.endsWith("/"):
result &= "/" result &= "/"
...@@ -25,16 +26,16 @@ proc validWordlist*(path: string): string = ...@@ -25,16 +26,16 @@ proc validWordlist*(path: string): string =
file can't be read file can't be read
]# ]#
if not fileExists(path): if not fileExists(path):
echo "[E] Invalid wordlist path" prntErr(path, "Invalid wordlist path")
return "" return ""
try: try:
let f = open(path, fmRead) let f = open(path, fmRead)
f.close() f.close()
result = path result = path
except IOError: except IOError:
echo "[E] Can't read file" prntErr(path, "Unable to read")
result = "" result = ""
except: except:
echo "[E] Unknown error" prntErr(path, "Unknown error")
echo getCurrentExceptionMsg() prntErr(path, getCurrentExceptionMsg())
result = "" result = ""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment