Commit b95730e3 authored by dmknght's avatar dmknght

Add prntErr and prntWarn

parent ccdff244
Pipeline #1133 canceled with stages
......@@ -11,7 +11,7 @@
{
"label": "[Test]Show user options",
"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 = "") =
......@@ -16,6 +17,28 @@ proc showHelpCmd*(app = "dirbnim", keyword = "help", value = "", descr = "") =
if value != "":
cmdOutput &= "\e[33m" & value & "\e[0m "
if descr != "":
cmdOutput &= "[\e[36m" & descr & "\e[0m]"
cmdOutput &= "[\e[36m" & descr & "\e[0m]" # Cyan color
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 os
import .. / cli / utils
proc urlFormat*(url: string): string =
......@@ -9,7 +10,7 @@ proc urlFormat*(url: string): string =
Outpt: URL: string
]#
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
if not result.endsWith("/"):
result &= "/"
......@@ -25,16 +26,16 @@ proc validWordlist*(path: string): string =
file can't be read
]#
if not fileExists(path):
echo "[E] Invalid wordlist path"
prntErr(path, "Invalid wordlist path")
return ""
try:
let f = open(path, fmRead)
f.close()
result = path
except IOError:
echo "[E] Can't read file"
prntErr(path, "Unable to read")
result = ""
except:
echo "[E] Unknown error"
echo getCurrentExceptionMsg()
prntErr(path, "Unknown error")
prntErr(path, getCurrentExceptionMsg())
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