aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-cli/src/meshbay_cli/commands
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-15 09:57:18 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-15 09:57:18 +0200
commit2f90f4b60cd50f7e9649daaf8e76a120e608cff6 (patch)
tree9d3724602959b05602f7fadb8a45bd26d0fc9b91 /packages/meshbay-cli/src/meshbay_cli/commands
parent5044bdfdfffceceecc0d92a776983ad361079839 (diff)
downloadmeshbay-2f90f4b60cd50f7e9649daaf8e76a120e608cff6.tar.gz
feat(cli): /put and /get in the interactive chat
/put FILE sends one local file, relative to the current directory or absolute, into the chat's folder, then posts the application's attachment message naming it ({"text": "", "attachment": {filename, size, type}}), so the page shows it as its paperclip's. /get NAME saves a file of that folder, named from it, into the current directory, never over a file already there. The chat's folder is the page's rule: the operator's choice while its root is writable and present, else the first such root; a chat_directory_ack moves it. A line above the one written in shows the transfer's progress. Attachment messages, from the page or from /put, read as [file: name, size] in the room and in `chat`, and as an `attachment` field with --json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-cli/src/meshbay_cli/commands')
-rw-r--r--packages/meshbay-cli/src/meshbay_cli/commands/chat.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/meshbay-cli/src/meshbay_cli/commands/chat.py b/packages/meshbay-cli/src/meshbay_cli/commands/chat.py
index d650af3..e410a6a 100644
--- a/packages/meshbay-cli/src/meshbay_cli/commands/chat.py
+++ b/packages/meshbay-cli/src/meshbay_cli/commands/chat.py
@@ -28,7 +28,7 @@ from ..client.groups import my_groups, open_group
from ..client.paths import group_arg, handle, resolve_group
from ..client.roster import RosterCheck
from ..errors import NODE, USAGE, CliError
-from ..output import date, err, safe, sentence
+from ..output import date, err, human_size, safe, sentence
from .context import Context
HELP = ("chat: alone, interactively; with a group, its last 10 messages (-N for N), "
@@ -147,6 +147,10 @@ def print_message(m, *, flush: bool = False) -> None:
print(f"{head}[this message cannot be read: {m.unreadable}]", flush=flush)
return
lines = safe_lines(m.text)
+ if m.attachment:
+ file_line = (f"[file: {safe(m.attachment['filename'])}, "
+ f"{human_size(m.attachment['size'])}]")
+ lines = [file_line] if lines == [""] else [file_line, *lines]
print(head + lines[0])
for line in lines[1:]:
print(" " * len(head) + line)
@@ -158,7 +162,8 @@ def print_message(m, *, flush: bool = False) -> None:
def as_json(m) -> dict:
return {"id": m.id, "timestamp": m.timestamp, "sender": m.sender, "text": m.text,
- "trust": m.trust, **({"unreadable": m.unreadable} if m.unreadable else {})}
+ "trust": m.trust, **({"unreadable": m.unreadable} if m.unreadable else {}),
+ **({"attachment": m.attachment} if m.attachment else {})}
class Follower: