35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# Copyright 2026 Umbra Tools (umbratools.com)
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from .server import MessageStore
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
parser = argparse.ArgumentParser(description="Read/write the local UmbraTrans agent bridge queue")
|
|
parser.add_argument("action", choices=("poll", "send", "status"))
|
|
parser.add_argument("--root", default="~/.local/state/umbratrans/agent-bridge")
|
|
parser.add_argument("--title", default="Mac agent")
|
|
parser.add_argument("--body", default="")
|
|
args = parser.parse_args(argv)
|
|
store = MessageStore(Path(args.root).expanduser())
|
|
if args.action == "poll":
|
|
print(json.dumps(store.poll_for_mac(20), ensure_ascii=False))
|
|
elif args.action == "send":
|
|
if not args.body:
|
|
parser.error("--body is required for send")
|
|
print(json.dumps(store.send_to_browser(args.body, args.title), ensure_ascii=False))
|
|
else:
|
|
print(json.dumps(store.status(), sort_keys=True))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|