26 lines
478 B
Nim
26 lines
478 B
Nim
import otp
|
|
import os
|
|
|
|
when isMainModule:
|
|
var
|
|
args = commandLineParams()
|
|
|
|
if args.len != 1:
|
|
quit "I need a machine name"
|
|
|
|
try:
|
|
var
|
|
keyFileName = args[0]
|
|
fin = open getEnv("HOME") / "life" / "crypto" / "totp" / keyFileName
|
|
key = fin.readLine
|
|
totp = newTotp key
|
|
|
|
echo totp.now()
|
|
|
|
except:
|
|
echo getCurrentExceptionMsg()
|
|
quit "Couldn't do that for " & args[0] & ". Does that machine exist in the store?"
|
|
|
|
else:
|
|
quit "invalid"
|