adjsuted pw gen
This commit is contained in:
parent
b866811ab8
commit
0f8b325246
2 changed files with 33 additions and 3 deletions
4
pw_generaturr/nimbledeps/nimbledata2.json
Normal file
4
pw_generaturr/nimbledeps/nimbledata2.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"version": 1,
|
||||
"reverseDeps": {}
|
||||
}
|
|
@ -1,11 +1,16 @@
|
|||
import ../../globurrl
|
||||
|
||||
#import ../../globurrl
|
||||
|
||||
import httpclient
|
||||
import json
|
||||
import strutils
|
||||
import random
|
||||
import parseopt
|
||||
import os
|
||||
|
||||
var length = 4
|
||||
var number = 10
|
||||
var word_len = 5
|
||||
|
||||
proc getNumber(size: int = 4): string =
|
||||
var num = ""
|
||||
|
@ -22,16 +27,37 @@ proc parsePw(body: string) =
|
|||
p &= getNumber(length)
|
||||
echo p
|
||||
|
||||
|
||||
proc getPW() =
|
||||
var c = newHttpClient()
|
||||
try:
|
||||
let resp = c.get("https://random-word-api.herokuapp.com/word?length=5")
|
||||
let resp = c.get("https://random-word-api.herokuapp.com/word?number=" & $number & "&length=" & $word_len)
|
||||
if resp.status == $Http200:
|
||||
parsePw(resp.body)
|
||||
|
||||
except:
|
||||
echo getCurrentExceptionMsg()
|
||||
|
||||
proc parseArgs() =
|
||||
var p = initOptParser(commandLineParams())
|
||||
while true:
|
||||
p.next()
|
||||
case p.kind
|
||||
of cmdEnd: break
|
||||
of cmdShortOption, cmdLongOption:
|
||||
if p.val == "":
|
||||
#echo "Option: ", p.key
|
||||
discard
|
||||
else:
|
||||
#echo "Option and value: ", p.key, ", ", p.val
|
||||
case p.key
|
||||
of "length":
|
||||
word_len = parseInt(p.val)
|
||||
of "number":
|
||||
number = parseInt(p.val)
|
||||
of cmdArgument:
|
||||
#echo "Argument: ", p.key
|
||||
discard
|
||||
|
||||
if isMainModule:
|
||||
parseArgs()
|
||||
getPW()
|
||||
|
|
Loading…
Reference in a new issue