forked from DGNum/liminix
pass event producer fn as param
This commit is contained in:
parent
0787807a7f
commit
ed9548f21d
2 changed files with 5 additions and 8 deletions
|
@ -33,7 +33,7 @@
|
|||
(when (. got params.expecting)
|
||||
(os.exit 0))))
|
||||
|
||||
(fn run []
|
||||
(fn run [event-fn]
|
||||
(let [parameters
|
||||
(assert (parse-args arg)
|
||||
(.. "Usage: " (. arg 0) " [-v] ifname [present|up|running]"))]
|
||||
|
@ -41,9 +41,9 @@
|
|||
(print (.. (. arg 0) ": waiting for "
|
||||
parameters.link " to be " parameters.expecting)))
|
||||
|
||||
(each [event (nl.events {:link true})]
|
||||
(each [event (event-fn)]
|
||||
(run-event parameters event))))
|
||||
|
||||
(when (not (= (. arg 0) "test")) (run))
|
||||
(when (not (= (. arg 0) "test")) (run #(nl.events {:link true})))
|
||||
|
||||
{ : run }
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
(local fennel (require :fennel))
|
||||
|
||||
(fn events [groups]
|
||||
(fn event-fn [groups]
|
||||
(let [data (with-open [e (io.open "events-fixture" "r")] (e:read "*a"))
|
||||
parse (fennel.parser data)]
|
||||
;(print data)
|
||||
(coroutine.wrap
|
||||
(fn []
|
||||
(each [ok ast parse]
|
||||
(if ok (coroutine.yield ast)))))))
|
||||
|
||||
(tset package.loaded :anoia.nl { :events events })
|
||||
|
||||
(set _G.arg (doto ["-v" "dummy0" "up"] (tset 0 "test")))
|
||||
|
||||
(local ifwait (require :ifwait))
|
||||
|
||||
(ifwait.run)
|
||||
(ifwait.run event-fn)
|
||||
|
|
Loading…
Reference in a new issue