Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Nong Hoang Tu
dirbnim
Commits
b95730e3
Commit
b95730e3
authored
Aug 30, 2020
by
dmknght
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add prntErr and prntWarn
parent
ccdff244
Pipeline
#1133
canceled with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
7 deletions
+31
-7
.vscode/tasks.json
.vscode/tasks.json
+1
-1
src/modules/cli/utils.nim
src/modules/cli/utils.nim
+24
-1
src/modules/cores/paramHandler.nim
src/modules/cores/paramHandler.nim
+6
-5
No files found.
.vscode/tasks.json
View file @
b95730e3
...
...
@@ -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
src/modules/cli/utils.nim
View file @
b95730e3
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
src/modules/cores/paramHandler.nim
View file @
b95730e3
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 = ""
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment