Minor changes, usage examples and selftests

This commit is contained in:
martin.holst@gmail.com 2013-09-21 20:46:32 +00:00
parent 70c8077c99
commit 450d2e3a96

View file

@ -2,7 +2,7 @@ local cmds = require('commands')
local getopt = require('getopt') local getopt = require('getopt')
local lib14a = require('read14a') local lib14a = require('read14a')
example = "script run writerraw -x 6000F57b" example = "script run 14araw -x 6000F57b"
author = "Martin Holst Swende" author = "Martin Holst Swende"
@ -21,14 +21,14 @@ Arguments:
Examples : Examples :
# 1. Connect and don't disconnect # 1. Connect and don't disconnect
script run writeraw -p script run 14araw -p
# 2. Send mf auth, read response (nonce) # 2. Send mf auth, read response (nonce)
script run writeraw -o -x 6000F57b -p script run 14araw -o -x 6000F57b -p
# 3. disconnect # 3. disconnect
script run writeraw -o script run 14araw -o
# All three steps in one go: # All three steps in one go:
script run writeraw -x 6000F57b script run 14araw -x 6000F57b
]] ]]
--[[ --[[
@ -52,7 +52,7 @@ local DEBUG = false -- the debug flag
-- A debug printout-function -- A debug printout-function
function dbg(args) function dbg(args)
if DEBUG then if DEBUG then
print("# ", args) print("###", args)
end end
end end
--- ---
@ -168,14 +168,18 @@ end
-- Testing -- Testing
------------------------- -------------------------
function selftest() function selftest()
DEBUG = true
dbg("Performing test")
main()
main("-p") main("-p")
main(" -o -x 6000F57b -p") main(" -o -x 6000F57b -p")
main("-o") main("-o")
main("-x 6000F57b") main("-x 6000F57b")
dbg("Tests done")
end end
-- Flip the switch here to perform a sanity check. -- Flip the switch here to perform a sanity check.
-- It read a nonce in two different ways, as specified in the usage-section -- It read a nonce in two different ways, as specified in the usage-section
if false then if "--test"==args then
selftest() selftest()
else else
-- Call the main -- Call the main