pretty traces and better script handling

This commit is contained in:
Florent 2025-10-29 19:57:07 +01:00
parent 4904e22ab8
commit 57f6cf5af9
2 changed files with 21 additions and 11 deletions

View file

@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "meshcore-cli" name = "meshcore-cli"
version = "1.1.37" version = "1.1.38"
authors = [ authors = [
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" }, { name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
] ]

View file

@ -23,7 +23,7 @@ from prompt_toolkit.shortcuts import radiolist_dialog
from meshcore import MeshCore, EventType, logger from meshcore import MeshCore, EventType, logger
# Version # Version
VERSION = "v1.1.37" VERSION = "v1.1.38"
# default ble address is stored in a config file # default ble address is stored in a config file
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/" MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@ -1801,18 +1801,26 @@ async def next_cmd(mc, cmds, json_output=False):
if json_output: if json_output:
print(json.dumps(ev.payload, indent=2)) print(json.dumps(ev.payload, indent=2))
else : else :
classic = interactive_loop.classic or not process_event_message.color
print("]",end="") print("]",end="")
for t in ev.payload["path"]: for t in ev.payload["path"]:
print("",end="") if classic :
print("",end="")
else:
print(f" {ANSI_INVERT}", end="")
snr = t['snr'] snr = t['snr']
if snr >= 10 : if snr >= 10 :
print(ANSI_GREEN, end="") print(ANSI_BGREEN, end="")
elif snr <= 0: elif snr <= 0:
print(ANSI_RED, end="") print(ANSI_BRED, end="")
else :
print(ANSI_BGRAY, end="")
print(f"{snr:.2f}",end="") print(f"{snr:.2f}",end="")
if snr >= 10 or snr <= 0: if classic :
print(ANSI_END, end="") print("",end="")
print("",end="") else :
print(f"{ANSI_NORMAL}🭬",end="")
print(ANSI_END, end="")
if "hash" in t: if "hash" in t:
print(f"[{t['hash']}]",end="") print(f"[{t['hash']}]",end="")
else: else:
@ -2427,9 +2435,11 @@ async def process_script(mc, file, json_output=False):
lines=f.readlines() lines=f.readlines()
for line in lines: for line in lines:
logger.debug(f"processing {line}") line = line.strip()
cmds = shlex.split(line[:-1]) if not (line == "" or line[0] == "#"):
await process_cmds(mc, cmds, json_output) logger.debug(f"processing {line}")
cmds = shlex.split(line)
await process_cmds(mc, cmds, json_output)
def version(): def version():
print (f"meshcore-cli: command line interface to MeshCore companion radios {VERSION}") print (f"meshcore-cli: command line interface to MeshCore companion radios {VERSION}")