diff --git a/README.md b/README.md index ca3f72b..ed66b26 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ An [open command](https://en.wikipedia.org/wiki/Open_(process)) implementation that uses [Syndicate](http://syndicate-lang.org/) and PCRE pattern matching to open URIs. -There are two utilites, `open` and `uri_runner`. The former connects to a shared Syndicate dataspace via a UNIX socket at `$SYNDICATE_SOCK` otherwise `$XDG_RUNTIME_DIR/dataspace` and has no other configuration. The `uri_runner` component is intended to be managed by the [Syndicate server](https://git.syndicate-lang.org/syndicate-lang/syndicate-rs) thru which it receives configuration, see [uri_runner.pr](./uri_runner.pr) as an example. +There are two utilites, `open` and `uri_runner`. The former connects to a shared Syndicate dataspace using a route at `$SYNDICATE_ROUTE` and has no other configuration. The `uri_runner` component is intended to be managed by the [Syndicate server](https://git.syndicate-lang.org/syndicate-lang/syndicate-rs) thru which it receives configuration, see [uri_runner.pr](./uri_runner.pr) as an example. Matching patterns to actions is done with `action-handler` records: ```preserves diff --git a/Tupfile b/Tupfile index 9368191..28c450e 100644 --- a/Tupfile +++ b/Tupfile @@ -1,3 +1,2 @@ include_rules -: |> !nim_lk |> | ./ : lock.json |> !nim_cfg |> | ./ diff --git a/lock.json b/lock.json index 8ff88e2..6e7cd50 100644 --- a/lock.json +++ b/lock.json @@ -1 +1 @@ -{"depends":[{"method":"fetchzip","packages":["syndicate"],"path":"/nix/store/008s11kkqscfqxs6g29q77c38pnrlppi-source","ref":"20231005","rev":"552e51899c82c0c2f4f466382be7d8e22a1da689","sha256":"1j3k0zlh5z02adhfvb7rdqz8fjzc6gri4v3v1fgcv2h2b7vrf0dg","srcDir":"src","url":"https://git.syndicate-lang.org/ehmry/syndicate-nim/archive/552e51899c82c0c2f4f466382be7d8e22a1da689.tar.gz"},{"method":"fetchzip","packages":["hashlib"],"path":"/nix/store/v03nzlpdgbfxd2zhcnkfbkq01d5kqxcl-source","rev":"84e0247555e4488594975900401baaf5bbbfb53","sha256":"1pfczsv8kl36qpv543f93d2y2vgz2acckssfap7l51s2x62m6qwx","srcDir":"","url":"https://github.com/khchen/hashlib/archive/84e0247555e4488594975900401baaf5bbbfb53.tar.gz"},{"method":"fetchzip","packages":["preserves"],"path":"/nix/store/vx6ihnickx7d5lwy69i8k7fsjicv33r3-source","ref":"20230914","rev":"c915accf7d2a36ca1f323e2f02e2df7375e815f1","sha256":"11rlcbs9mvk335ibkbj8fk9aslhmnlaiqhcsjpp5n04k447sr7nx","srcDir":"src","url":"https://git.syndicate-lang.org/ehmry/preserves-nim/archive/c915accf7d2a36ca1f323e2f02e2df7375e815f1.tar.gz"},{"method":"fetchzip","packages":["nimcrypto"],"path":"/nix/store/zyr8zwh7vaiycn1s4r8cxwc71f2k5l0h-source","ref":"traditional-api","rev":"602c5d20c69c76137201b5d41f788f72afb95aa8","sha256":"1dmdmgb6b9m5f8dyxk781nnd61dsk3hdxqks7idk9ncnpj9fng65","srcDir":"","url":"https://github.com/cheatfate/nimcrypto/archive/602c5d20c69c76137201b5d41f788f72afb95aa8.tar.gz"},{"method":"fetchzip","packages":["npeg"],"path":"/nix/store/ffkxmjmigfs7zhhiiqm0iw2c34smyciy-source","ref":"1.2.1","rev":"26d62fdc40feb84c6533956dc11d5ee9ea9b6c09","sha256":"0xpzifjkfp49w76qmaylan8q181bs45anmp46l4bwr3lkrr7bpwh","srcDir":"src","url":"https://github.com/zevv/npeg/archive/26d62fdc40feb84c6533956dc11d5ee9ea9b6c09.tar.gz"}]} +{"depends":[{"method":"fetchzip","packages":["hashlib"],"path":"/nix/store/v03nzlpdgbfxd2zhcnkfbkq01d5kqxcl-source","rev":"84e0247555e4488594975900401baaf5bbbfb53","sha256":"1pfczsv8kl36qpv543f93d2y2vgz2acckssfap7l51s2x62m6qwx","srcDir":"","url":"https://github.com/khchen/hashlib/archive/84e0247555e4488594975900401baaf5bbbfb53.tar.gz"},{"method":"fetchzip","packages":["nimcrypto"],"path":"/nix/store/zyr8zwh7vaiycn1s4r8cxwc71f2k5l0h-source","ref":"traditional-api","rev":"602c5d20c69c76137201b5d41f788f72afb95aa8","sha256":"1dmdmgb6b9m5f8dyxk781nnd61dsk3hdxqks7idk9ncnpj9fng65","srcDir":"","url":"https://github.com/cheatfate/nimcrypto/archive/602c5d20c69c76137201b5d41f788f72afb95aa8.tar.gz"},{"method":"fetchzip","packages":["npeg"],"path":"/nix/store/ffkxmjmigfs7zhhiiqm0iw2c34smyciy-source","ref":"1.2.1","rev":"26d62fdc40feb84c6533956dc11d5ee9ea9b6c09","sha256":"0xpzifjkfp49w76qmaylan8q181bs45anmp46l4bwr3lkrr7bpwh","srcDir":"src","url":"https://github.com/zevv/npeg/archive/26d62fdc40feb84c6533956dc11d5ee9ea9b6c09.tar.gz"},{"method":"fetchzip","packages":["preserves"],"path":"/nix/store/nrcpzf9hx70kry3gwhrdzcs3qicjncjh-source","ref":"20231021","rev":"edece399be70818208bf2263c30cb2bcf435bbff","sha256":"0xmw35wmw3a4lja9q4qvlvpxv3xk0hnkjg4fwfw6f3inh6zfiqki","srcDir":"src","url":"https://git.syndicate-lang.org/ehmry/preserves-nim/archive/edece399be70818208bf2263c30cb2bcf435bbff.tar.gz"},{"method":"fetchzip","packages":["syndicate"],"path":"/nix/store/1y3nnpp2mhxqmdb3xh4c4k5k5l9hhqk3-source","ref":"20231019","rev":"57b99b20e7db1b97b1cb9c6df574bd13983c26fc","sha256":"1kgb3a78igs37xkmv8cbaxa17qdjf2h43vdmpda517c9086ggsn5","srcDir":"src","url":"https://git.syndicate-lang.org/ehmry/syndicate-nim/archive/57b99b20e7db1b97b1cb9c6df574bd13983c26fc.tar.gz"}]} diff --git a/src/open.nim b/src/open.nim index b27e3f5..9c07f48 100644 --- a/src/open.nim +++ b/src/open.nim @@ -5,16 +5,6 @@ import std/[asyncdispatch, os, uri] import preserves, syndicate, syndicate/relays, syndicate/capabilities import ./protocol, ./common -proc unixSocketPath: Unix = - result.path = getEnv("SYNDICATE_SOCK") - if result.path == "": - result.path = getEnv("XDG_RUNTIME_DIR", "/run/user/1000") / "dataspace" - -proc envStep: Assertion = - var s = getEnv("SYNDICATE_STEP") - if s != "": parsePreserves(s, Cap) - else: capabilities.mint().toPreserve(Cap) - proc publishUri(turn: var Turn; ds: Cap) = for arg in commandLineParams(): if fileExists(arg): @@ -25,9 +15,9 @@ proc publishUri(turn: var Turn; ds: Cap) = stop(turn) proc main = - let step = envStep() + let route = envRoute() discard bootDataspace("open") do (root: Cap; turn: var Turn): - connect(turn, unixSocketPath(), step, publishUri) + resolve(turn, root, route, publishUri) for i in 0..4: poll(20) # A hack to exit diff --git a/src/uri_runner.nim b/src/uri_runner.nim index 893d013..baa7587 100644 --- a/src/uri_runner.nim +++ b/src/uri_runner.nim @@ -18,7 +18,7 @@ proc rewrite(result: var Assertion; uri: string; regex: Regex) {.gcsafe.} = apply(result, op) runActor("main") do (root: Cap; turn: var Turn): - connectStdio(root, turn) + connectStdio(turn, root) let handlers = newTable[Handle, RegexAction]() during(turn, root, ?UriRunnerConfig) do (handlerspace: Cap, urispace: Cap): diff --git a/syndicated_open.nimble b/syndicated_open.nimble index 6aae95a..b83ced5 100644 --- a/syndicated_open.nimble +++ b/syndicated_open.nimble @@ -1,6 +1,6 @@ # Package -version = "20231010" +version = "20231021" author = "Emery" description = "Syndicated open command" license = "Unlicense" @@ -10,4 +10,4 @@ bin = @[ "open", "uri_runner"] # Dependencies -requires "nim >= 1.6.4", "syndicate >= 20230630" +requires "nim >= 1.6.4", "syndicate >= 20231021"