Commit ea1f0ce1 authored by dmknght's avatar dmknght

Add basic args and test

parent b5927643
Pipeline #1131 canceled with stages
......@@ -7,6 +7,11 @@
"label": "[Test]Show help banner",
"type": "shell",
"command": "nim c -r src/test/testcli.nim"
},
{
"label": "[Test]Show user options",
"type": "shell",
"command": "nim c -r src/test/testargs.nim http://a.b -w x"
}
]
}
\ No newline at end of file
# import tables
import os
# import strutils
type
DirbOptions* = object
url*: string
wordlist*: string
cookie*: string
agent*: string
proc getOptions*(): DirbOptions =
var allOptions: DirbOptions
allOptions = DirbOptions(wordlist: "/usr/share/wordlists/common.txt")
let
szArgs = paramCount()
helpKeywords = ["help", "--help", "-h", "--h", "-help"]
case szArgs:
of 0:
discard # TODO fast help and exit
of 1:
if paramStr(1) in helpKeywords:
discard # TODO fast help and exit
else:
# TODO move this block to 1 proc: add and get url?
allOptions.url = paramStr(1)
# TODO handleURL here
else:
var i = 1
while i < szArgs:
case paramStr(i):
of "-w":
allOptions.wordlist = paramStr(i + 1)
# TODO check if path exist
# TODO check read file perm okay
of "-c":
allOptions.cookie = paramStr(i + 1)
of "-a":
allOptions.agent = paramStr(i + 1)
else:
# TODO move this block to 1 proc: add and get url?
allOptions.url = paramStr(i)
# TODO handle URL here
i -= 1
i += 2
return allOptions
import ../ modules / cli / options
let userOptions = getOptions()
echo userOptions
\ No newline at end of file
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