diff --git a/README.md b/README.md index 9179314..063bc7f 100644 --- a/README.md +++ b/README.md @@ -374,14 +374,3 @@ Example script: This utility serializes it's process environment to Preserves and prints it to stdout. It can be used to feed the environment variables of a nested child of the Syndicate server back to the server. For example, to retreive the environmental variables that a desktop manager passed on to its children. - - -## syndump - -Utility for printing assertions and messages. Parses the command-line arguments as a pattern, connects a dataspace via `$SYNDICATE_ROUTE`, and writes observations to standard-output. Published assertions are prefixed by the `+` character, retractions by `-`, and messages by `!`. - -Example -```sh -# Print patterns in use, filter down with AWK to only the published patterns. -$ FS=':' syndump '' | awk -F : '/^+/ { print $2 }' -``` diff --git a/src/syndump.nim b/src/syndump.nim deleted file mode 100644 index 2db0ee7..0000000 --- a/src/syndump.nim +++ /dev/null @@ -1,73 +0,0 @@ -# SPDX-FileCopyrightText: ☭ Emery Hemingway -# SPDX-License-Identifier: Unlicense - -import std/[os, tables] -import preserves, syndicate, syndicate/[durings, relays] - -proc parsePattern(pr: Value): Pattern = - let - dropSigil = initRecord("lit", "_".toSymbol) - grabSigil = initRecord("lit", "?".toSymbol) - var pr = grab(pr).toPreserves - apply(pr) do (pr: var Value): - if pr == dropSigil: - pr = initRecord("_") - elif pr == grabSigil: - pr = initRecord("bind", initRecord("_")) - doAssert result.fromPreserves(pr) - -proc inputPatterns: seq[Pattern] = - var args = commandLineParams() - result.setLen(args.len) - for i, input in args: - try: result[i] = input.parsePreserves.parsePattern - except ValueError: - quit "failed to parse Preserves argument" - -type DumpEntity {.final.} = ref object of Entity - assertions: Table[Handle, seq[Value]] - -proc toLine(values: seq[Value]; prefix: char): string = - result = newStringOfCap(1024) - let sep = getEnv("FS", " ") - result.add(prefix) - for v in values: - add(result, sep) - add(result, $v) - add(result, '\n') - -method publish(dump: DumpEntity; turn: var Turn; ass: AssertionRef; h: Handle) = - var values = ass.value.sequence - stdout.write(values.toLine('+')) - stdout.flushFile() - dump.assertions[h] = values - -method retract(dump: DumpEntity; turn: var Turn; h: Handle) = - var values: seq[Value] - if dump.assertions.pop(h, values): - stdout.write(values.toLine('-')) - stdout.flushFile() - -method message*(dump: DumpEntity; turn: var Turn; ass: AssertionRef) = - stdout.write(ass.value.sequence.toLine('!')) - stdout.flushFile() - -proc exitProc() {.noconv.} = - stdout.write('\n') - quit() - -proc main = - let - route = envRoute() - patterns = inputPatterns() - entity = DumpEntity() - runActor("syndex_card") do (root: Cap; turn: var Turn): - for pat in patterns: - discard observe(turn, root, pat, entity) - spawnRelays(turn, root) - resolve(turn, root, route) do (turn: var Turn; ds: Cap): - for pat in patterns: - discard observe(turn, ds, pat, entity) - -setControlCHook(exitProc) -main() diff --git a/syndicate_utils.nimble b/syndicate_utils.nimble index bfc63b0..bafcb1e 100644 --- a/syndicate_utils.nimble +++ b/syndicate_utils.nimble @@ -5,9 +5,9 @@ author = "Emery Hemingway" description = "Utilites for Syndicated Actors and Synit" license = "unlicense" srcDir = "src" -bin = @["mintsturdyref", "mount_actor", "msg", "net_mapper", "preserve_process_environment", "syndesizer", "syndex_card", "syndump"] +bin = @["mintsturdyref", "mount_actor", "msg", "net_mapper", "preserve_process_environment", "syndesizer", "syndex_card"] # Dependencies -requires "nim >= 2.0.0", "illwill", "syndicate >= 20240208", "ws" +requires "nim >= 2.0.0", "illwill", "syndicate >= 20240208", "ws", "https://github.com/ehmry/nim-sys.git#b974e1a4ca6ae7d89fc9e7b3714b1e7daf6f33e5", "https://github.com/nim-works/cps"