Skip to content

Commit e1ddd03

Browse files
committed
display min hours or days in neighbours
1 parent af791fe commit e1ddd03

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/meshcore_cli/meshcore_cli.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,15 +2610,30 @@ async def next_cmd(mc, cmds, json_output=False):
26102610
if json_output:
26112611
print(json.dumps(res, indent=4))
26122612
else:
2613+
width = os.get_terminal_size().columns
26132614
print(f"Got {res['results_count']} neighbours out of {res['neighbours_count']} from {contact['adv_name']}:")
26142615
for n in res['neighbours']:
26152616
ct = mc.get_contact_by_key_prefix(n["pubkey"])
2616-
if ct :
2617+
if ct and width > 60 :
26172618
name = f"[{n['pubkey'][0:8]}] {ct['adv_name']}"
2619+
name = f"{name:30}"
2620+
elif ct :
2621+
name = f"{ct['adv_name']}"
2622+
name = f"{name:20}"
26182623
else:
26192624
name = f"[{n['pubkey']}]"
26202625

2621-
print(f" {name:30} last viewed {n['secs_ago']} sec ago at {n['snr']} ")
2626+
t_s = n['secs_ago']
2627+
time_ago = f"{t_s}s"
2628+
if t_s / 86400 >= 1 : # result in days
2629+
time_ago = f"{int(t_s/86400)}d ago{f' ({time_ago})' if width > 62 else ''}"
2630+
elif t_s / 3600 >= 1 : # result in days
2631+
time_ago = f"{int(t_s/3600)}h ago{f' ({time_ago})' if width > 62 else ''}"
2632+
elif t_s / 60 >= 1 : # result in min
2633+
time_ago = f"{int(t_s/60)}m ago{f' ({time_ago})' if width > 62 else ''}"
2634+
2635+
2636+
print(f" {name} {time_ago}, {n['snr']}dB{' SNR' if width > 66 else ''}")
26222637

26232638
case "req_binary" :
26242639
argnum = 2

0 commit comments

Comments
 (0)