summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-cli/src/meshbay_cli/commands/groups.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-15 00:56:04 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-15 00:56:04 +0200
commit6f68bb6c1970e26de1f66c073ea5d7fecd21840d (patch)
tree859c74db5819f1d49046e71a53e12afe5eb4193a /packages/meshbay-cli/src/meshbay_cli/commands/groups.py
parent16d92c96bde3a65fc54a93b4662df30cafc831e4 (diff)
downloadmeshbay-6f68bb6c1970e26de1f66c073ea5d7fecd21840d.tar.gz
feat(cli): invitations, join, decline, leave, devices, browser access
join accepts an invitation or redeems a link pasted as sent, then has the node admit a key pair made here, with the invitation's code (a link's code goes only to the node it names; one for a node that is away is kept for the next connection). decline, leave and devices revoke ask first, and refuse without --yes where there is no terminal. devices approve countersigns the one waiting request a code matches, none when several do. browser-access is the application's setting, kept per machine and never enabled from the hub's mirror: on leaves a copy sealed under M on each node, off withdraws it, unset touches nothing. A key pair made for a first contact is now kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-cli/src/meshbay_cli/commands/groups.py')
-rw-r--r--packages/meshbay-cli/src/meshbay_cli/commands/groups.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/packages/meshbay-cli/src/meshbay_cli/commands/groups.py b/packages/meshbay-cli/src/meshbay_cli/commands/groups.py
index 7595e2b..04395dd 100644
--- a/packages/meshbay-cli/src/meshbay_cli/commands/groups.py
+++ b/packages/meshbay-cli/src/meshbay_cli/commands/groups.py
@@ -7,12 +7,15 @@ it. "owner" is the account that created the group on the hub — a node's
operator is another notion.
"""
+import contextlib
import json
import sys
from datetime import datetime
from ..client.groups import my_groups
+from ..client.hub import HubError
from ..client.paths import handle
+from ..errors import CliError
from ..output import safe, sentence
from .context import Context
@@ -31,7 +34,7 @@ def node_state(g: dict) -> str:
return "up" if g.get("node_online") else "down"
-def _when(iso: str | None) -> str:
+def local_time(iso: str | None) -> str:
if not iso:
return ""
try:
@@ -45,6 +48,11 @@ async def run(ctx: Context) -> int:
account = ctx.account()
try:
groups = await my_groups(account)
+ waiting = 0
+ if not ctx.args.json and not ctx.args.quiet:
+ # A hub without invitations answers nothing useful; the list stands.
+ with contextlib.suppress(HubError, CliError):
+ waiting = len(await account.call(account.hub.invitations))
finally:
await account.close()
groups.sort(key=lambda g: (g["name"].lower(), g.get("owner_username") or ""))
@@ -58,6 +66,9 @@ async def run(ctx: Context) -> int:
for g in groups], sys.stdout, indent=1)
print()
return 0
+ if waiting:
+ print(f"{waiting} invitation{'s' if waiting != 1 else ''} waiting for your answer: "
+ "meshbay-cli invitations", file=sys.stderr)
if not groups:
print("You belong to no group yet.", file=sys.stderr)
return 0
@@ -65,5 +76,5 @@ async def run(ctx: Context) -> int:
for g in groups:
role = "owner" if g.get("is_admin") else "member"
print(f"{node_state(g):<6}{role:<8}{safe(g.get('visibility') or ''):<12}"
- f"{_when(g.get('last_activity_at')):<18}{safe(handle(g))}")
+ f"{local_time(g.get('last_activity_at')):<18}{safe(handle(g))}")
return 0