mirror of
https://github.com/meshcore-dev/meshcore-cli.git
synced 2026-04-20 22:13:48 +00:00
display min hours or days in neighbours
This commit is contained in:
parent
af791fea50
commit
e1ddd030b4
1 changed files with 17 additions and 2 deletions
|
|
@ -2610,15 +2610,30 @@ async def next_cmd(mc, cmds, json_output=False):
|
||||||
if json_output:
|
if json_output:
|
||||||
print(json.dumps(res, indent=4))
|
print(json.dumps(res, indent=4))
|
||||||
else:
|
else:
|
||||||
|
width = os.get_terminal_size().columns
|
||||||
print(f"Got {res['results_count']} neighbours out of {res['neighbours_count']} from {contact['adv_name']}:")
|
print(f"Got {res['results_count']} neighbours out of {res['neighbours_count']} from {contact['adv_name']}:")
|
||||||
for n in res['neighbours']:
|
for n in res['neighbours']:
|
||||||
ct = mc.get_contact_by_key_prefix(n["pubkey"])
|
ct = mc.get_contact_by_key_prefix(n["pubkey"])
|
||||||
if ct :
|
if ct and width > 60 :
|
||||||
name = f"[{n['pubkey'][0:8]}] {ct['adv_name']}"
|
name = f"[{n['pubkey'][0:8]}] {ct['adv_name']}"
|
||||||
|
name = f"{name:30}"
|
||||||
|
elif ct :
|
||||||
|
name = f"{ct['adv_name']}"
|
||||||
|
name = f"{name:20}"
|
||||||
else:
|
else:
|
||||||
name = f"[{n['pubkey']}]"
|
name = f"[{n['pubkey']}]"
|
||||||
|
|
||||||
print(f" {name:30} last viewed {n['secs_ago']} sec ago at {n['snr']} ")
|
t_s = n['secs_ago']
|
||||||
|
time_ago = f"{t_s}s"
|
||||||
|
if t_s / 86400 >= 1 : # result in days
|
||||||
|
time_ago = f"{int(t_s/86400)}d ago{f' ({time_ago})' if width > 62 else ''}"
|
||||||
|
elif t_s / 3600 >= 1 : # result in days
|
||||||
|
time_ago = f"{int(t_s/3600)}h ago{f' ({time_ago})' if width > 62 else ''}"
|
||||||
|
elif t_s / 60 >= 1 : # result in min
|
||||||
|
time_ago = f"{int(t_s/60)}m ago{f' ({time_ago})' if width > 62 else ''}"
|
||||||
|
|
||||||
|
|
||||||
|
print(f" {name} {time_ago}, {n['snr']}dB{' SNR' if width > 66 else ''}")
|
||||||
|
|
||||||
case "req_binary" :
|
case "req_binary" :
|
||||||
argnum = 2
|
argnum = 2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue