add when isMainModule
This commit is contained in:
parent
0ff50fcbe4
commit
4bec75a3b6
21
totptool.nim
21
totptool.nim
|
@ -38,12 +38,13 @@ proc writeVersion() =
|
|||
echo gitlog
|
||||
quit 1
|
||||
|
||||
var
|
||||
when isMainModule:
|
||||
var
|
||||
totpRoot: string = getHomeDir() / "life" / "crypto" / "totp"
|
||||
command: string
|
||||
args: seq[string]
|
||||
|
||||
for kind, key, val in getopt():
|
||||
for kind, key, val in getopt():
|
||||
case kind
|
||||
of cmdArgument:
|
||||
if command == nil:
|
||||
|
@ -71,21 +72,21 @@ for kind, key, val in getopt():
|
|||
|
||||
of cmdEnd: assert(false) # cannot happen
|
||||
|
||||
if command == nil:
|
||||
if command == nil:
|
||||
writeHelp()
|
||||
else: discard
|
||||
else: discard
|
||||
|
||||
if not existsDir(totpRoot):
|
||||
if not existsDir(totpRoot):
|
||||
totpRoot.createDir
|
||||
echo "Created totp root " & totpRoot
|
||||
|
||||
case command
|
||||
of "code":
|
||||
case command
|
||||
of "code":
|
||||
code(totpRoot, args)
|
||||
of "newSecret":
|
||||
of "newSecret":
|
||||
newSecret(totpRoot, args)
|
||||
of "ls":
|
||||
of "ls":
|
||||
ls(totpRoot, args)
|
||||
else:
|
||||
else:
|
||||
echo "Command " & command & " not found."
|
||||
writeHelp()
|
||||
|
|
Loading…
Reference in New Issue