diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3c10d5c7f01bb29e1b78c7fe0efa6848ba21b32c..f1afb10eaa36da7b7eabdf6c2bb224d699bdafee 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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 diff --git a/src/modules/cli/utils.nim b/src/modules/cli/utils.nim index 20f8b92532f228bb9afe79cbe6698d6c00f2f423..52980de7d33571bd8383afd483f7d6b13fe08ce2 100644 --- a/src/modules/cli/utils.nim +++ b/src/modules/cli/utils.nim @@ -1,3 +1,4 @@ +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 diff --git a/src/modules/cores/paramHandler.nim b/src/modules/cores/paramHandler.nim index 871a9b404820d9dd5d4b4d505997eb98b82307f9..d37e780e8f7ac6c3d4806b37bb9443aa09259002 100644 --- a/src/modules/cores/paramHandler.nim +++ b/src/modules/cores/paramHandler.nim @@ -1,5 +1,6 @@ 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 = ""