forked from DGNum/liminix
pass command line params to run instead of reffing global
This commit is contained in:
parent
725af00dc9
commit
570d29c368
2 changed files with 8 additions and 11 deletions
|
@ -32,18 +32,19 @@
|
|||
{})]
|
||||
(. got params.expecting)))
|
||||
|
||||
(fn run [event-fn]
|
||||
(fn run [args event-fn]
|
||||
(let [parameters
|
||||
(assert (parse-args arg)
|
||||
(.. "Usage: " (. arg 0) " [-v] ifname [present|up|running]"))]
|
||||
(assert (parse-args args)
|
||||
(.. "Usage: ifwait [-v] ifname [present|up|running]"))]
|
||||
(when parameters.verbose
|
||||
(print (.. (. arg 0) ": waiting for "
|
||||
(print (.. "ifwait: waiting for "
|
||||
parameters.link " to be " parameters.expecting)))
|
||||
|
||||
(each [e (event-fn)
|
||||
&until (run-event parameters e)]
|
||||
true)))
|
||||
|
||||
(when (not (= (. arg 0) "test")) (run #(nl.events {:link true})))
|
||||
(when (not (= (. arg 0) "test"))
|
||||
(run arg #(nl.events {:link true})))
|
||||
|
||||
{ : run }
|
||||
|
|
|
@ -11,15 +11,11 @@
|
|||
(icollect [_ ast parse]
|
||||
ast)))
|
||||
|
||||
|
||||
(set _G.arg (doto ["-v" "dummy0" "up"] (tset 0 "test")))
|
||||
|
||||
(set _G.arg (doto [] (tset 0 "test")))
|
||||
(local ifwait (require :ifwait))
|
||||
|
||||
|
||||
|
||||
(let [gen (event-generator (file-events "events-fixture"))]
|
||||
(ifwait.run #gen)
|
||||
(ifwait.run ["-v" "dummy0" "up"] #gen)
|
||||
(match (pcall gen)
|
||||
(true _) true
|
||||
(false msg) (error "didn't detect dummy0 up event")))
|
||||
|
|
Loading…
Reference in a new issue