syndicate_utils/src/msg.nim

23 lines
615 B
Nim
Raw Permalink Normal View History

# SPDX-FileCopyrightText: ☭ Emery Hemingway
# SPDX-License-Identifier: Unlicense
2024-04-07 13:16:51 +00:00
import std/[sequtils, os, strutils]
2023-10-21 18:03:11 +00:00
import preserves, syndicate, syndicate/relays
2024-04-07 13:16:51 +00:00
setControlCHook(proc () {.noconv.} = quit())
2024-04-30 11:56:48 +00:00
runActor("msg") do (turn: Turn):
2024-04-07 13:16:51 +00:00
let
data = map(commandLineParams(), parsePreserves)
cmd = paramStr(0).extractFilename.normalize
2024-04-30 11:56:48 +00:00
resolveEnvironment(turn) do (turn: Turn; ds: Cap):
2024-04-07 13:16:51 +00:00
case cmd
of "assert":
for e in data:
publish(turn, ds, e)
else: # "msg"
for e in data:
message(turn, ds, e)
2024-04-30 11:56:48 +00:00
sync(turn, ds) do (turn: Turn):
2024-04-07 13:16:51 +00:00
stopActor(turn)