2023-05-18 09:46:17 +00:00
|
|
|
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
2022-02-26 23:39:22 +00:00
|
|
|
# SPDX-License-Identifier: Unlicense
|
|
|
|
|
2023-06-30 14:26:22 +00:00
|
|
|
import std/[asyncdispatch, os, uri]
|
2023-10-10 08:04:59 +00:00
|
|
|
import preserves, syndicate, syndicate/relays, syndicate/capabilities
|
2023-06-30 14:26:22 +00:00
|
|
|
import ./protocol, ./common
|
2022-02-26 23:39:22 +00:00
|
|
|
|
2023-10-10 08:04:59 +00:00
|
|
|
proc publishUri(turn: var Turn; ds: Cap) =
|
2023-05-18 09:46:17 +00:00
|
|
|
for arg in commandLineParams():
|
2023-06-30 14:26:22 +00:00
|
|
|
if fileExists(arg):
|
|
|
|
message(turn, ds, Open(uri: protocol.Uri(
|
|
|
|
scheme: "file", path: arg.absolutePath.toPreserve)))
|
|
|
|
else:
|
|
|
|
message(turn, ds, initRecord("open", arg.parseUri.toPreserve))
|
2023-05-18 09:46:17 +00:00
|
|
|
stop(turn)
|
|
|
|
|
2023-10-10 08:04:59 +00:00
|
|
|
proc main =
|
2023-10-21 17:52:59 +00:00
|
|
|
let route = envRoute()
|
2023-10-10 08:04:59 +00:00
|
|
|
discard bootDataspace("open") do (root: Cap; turn: var Turn):
|
2023-10-21 17:52:59 +00:00
|
|
|
resolve(turn, root, route, publishUri)
|
2022-02-26 23:39:22 +00:00
|
|
|
|
2023-10-10 08:04:59 +00:00
|
|
|
for i in 0..4: poll(20)
|
|
|
|
# A hack to exit
|
2022-02-26 23:39:22 +00:00
|
|
|
|
2023-10-10 08:04:59 +00:00
|
|
|
main()
|