Use the "during" macro

This commit is contained in:
Emery Hemingway 2022-04-23 18:32:43 -05:00
parent 1c22d61d0f
commit 074eb4ec16
3 changed files with 9 additions and 8 deletions

View File

@ -14,7 +14,6 @@ bootDataspace("main") do (root: Ref; turn: var Turn):
connectStdio(root, turn)
onPublish(turn, root, ?ActionHandler) do (pat: string; cmd: seq[Assertion]):
# TODO: during
if cmd.len < 2:
stderr.writeLine "ignoring ", $cmd, " for ", pat
else:
@ -24,7 +23,7 @@ bootDataspace("main") do (root: Ref; turn: var Turn):
else:
stderr.writeLine "not a valid program specification: ", cmd[0]
onPublish(turn, root, ?ListenOn[Ref]) do (a: Assertion):
during(turn, root, ?ListenOn[Ref]) do (a: Assertion):
let ds = unembed a
onMessage(turn, ds, ?XdgOpen) do (uris: seq[string]):
while children.len > 0 and not children.peekFirst.running:
@ -52,5 +51,9 @@ bootDataspace("main") do (root: Ref; turn: var Turn):
children.addLast child
if not matched:
stderr.writeLine "no actions matched for ", uri
do:
# The Syndicate server retracts all assertions when
# the config is rewritten.
actions.setLen 0
runForever()

View File

@ -15,10 +15,8 @@ proc mintCap: SturdyRef =
var key: array[16, byte]
mint(key, "syndicate")
bootDataspace("main") do (ds: Ref; turn: var Turn):
let mainFacet = turn.facet
connectUnix(turn, unixSocketPath(), mintCap()) do (turn: var Turn; a: Assertion) -> TurnAction:
let ds = unembed a
bootDataspace("main") do (root: Ref; turn: var Turn):
connectUnix(turn, unixSocketPath(), mintCap()) do (turn: var Turn; ds: Ref):
message(turn, ds, XdgOpen(uris: commandLineParams()))
for i in 0..7: poll(20)

View File

@ -1,6 +1,6 @@
# Package
version = "0.3.0"
version = "0.3.1"
author = "Emery"
description = "A better xdg-open"
license = "Unlicense"
@ -10,4 +10,4 @@ bin = @[ "uri_runner", "xdg_open"]
# Dependencies
requires "nim >= 1.6.4", "syndicate"
requires "nim >= 1.6.4", "syndicate >= 1.3.0"