implement ls command
This commit is contained in:
parent
713e74060f
commit
2686b19535
|
@ -0,0 +1,18 @@
|
|||
import algorithm
|
||||
import os
|
||||
import strutils
|
||||
|
||||
const lsUsage =
|
||||
"""Usage: totptool ls
|
||||
|
||||
Shows all of the totp codes available.
|
||||
"""
|
||||
|
||||
proc help*() =
|
||||
echo lsUsage
|
||||
quit 2
|
||||
|
||||
proc ls*(root: string, args: seq[string]) =
|
||||
for file in walkFiles root / "*":
|
||||
var name = file.split("/")
|
||||
echo name.reversed[0]
|
16
totptool.nim
16
totptool.nim
|
@ -4,6 +4,7 @@ import parseopt2
|
|||
# Subcommands
|
||||
import cmds/code
|
||||
import cmds/gen
|
||||
import cmds/ls
|
||||
|
||||
const usageHelp =
|
||||
"""Usage: totptool [options] <command> [args]
|
||||
|
@ -54,11 +55,9 @@ for kind, key, val in getopt():
|
|||
case key
|
||||
of "help", "h":
|
||||
case command
|
||||
of "code":
|
||||
code.help()
|
||||
of "gen":
|
||||
gen.help()
|
||||
of "ls": discard
|
||||
of "code": code.help()
|
||||
of "gen": gen.help()
|
||||
of "ls": ls.help()
|
||||
else:
|
||||
writeHelp()
|
||||
|
||||
|
@ -78,10 +77,9 @@ if not existsDir(totpRoot):
|
|||
echo "Created totp root " & totpRoot
|
||||
|
||||
case command
|
||||
of "code":
|
||||
code(totpRoot, args)
|
||||
of "gen":
|
||||
gen(totpRoot, args)
|
||||
of "code": code totpRoot, args
|
||||
of "gen": gen totpRoot, args
|
||||
of "ls": ls totpRoot, args
|
||||
else:
|
||||
echo "Command " & command & " not found."
|
||||
writeHelp()
|
||||
|
|
Loading…
Reference in New Issue