Skip to content

Commit 57f6cf5

Browse files
committed
pretty traces and better script handling
1 parent 4904e22 commit 57f6cf5

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "meshcore-cli"
7-
version = "1.1.37"
7+
version = "1.1.38"
88
authors = [
99
{ name="Florent de Lamotte", email="[email protected]" },
1010
]

src/meshcore_cli/meshcore_cli.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from meshcore import MeshCore, EventType, logger
2424

2525
# Version
26-
VERSION = "v1.1.37"
26+
VERSION = "v1.1.38"
2727

2828
# default ble address is stored in a config file
2929
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -1801,18 +1801,26 @@ async def next_cmd(mc, cmds, json_output=False):
18011801
if json_output:
18021802
print(json.dumps(ev.payload, indent=2))
18031803
else :
1804+
classic = interactive_loop.classic or not process_event_message.color
18041805
print("]",end="")
18051806
for t in ev.payload["path"]:
1806-
print("→",end="")
1807+
if classic :
1808+
print("→",end="")
1809+
else:
1810+
print(f" {ANSI_INVERT}", end="")
18071811
snr = t['snr']
18081812
if snr >= 10 :
1809-
print(ANSI_GREEN, end="")
1813+
print(ANSI_BGREEN, end="")
18101814
elif snr <= 0:
1811-
print(ANSI_RED, end="")
1815+
print(ANSI_BRED, end="")
1816+
else :
1817+
print(ANSI_BGRAY, end="")
18121818
print(f"{snr:.2f}",end="")
1813-
if snr >= 10 or snr <= 0:
1814-
print(ANSI_END, end="")
1815-
print("→",end="")
1819+
if classic :
1820+
print("→",end="")
1821+
else :
1822+
print(f"{ANSI_NORMAL}🭬",end="")
1823+
print(ANSI_END, end="")
18161824
if "hash" in t:
18171825
print(f"[{t['hash']}]",end="")
18181826
else:
@@ -2427,9 +2435,11 @@ async def process_script(mc, file, json_output=False):
24272435
lines=f.readlines()
24282436

24292437
for line in lines:
2430-
logger.debug(f"processing {line}")
2431-
cmds = shlex.split(line[:-1])
2432-
await process_cmds(mc, cmds, json_output)
2438+
line = line.strip()
2439+
if not (line == "" or line[0] == "#"):
2440+
logger.debug(f"processing {line}")
2441+
cmds = shlex.split(line)
2442+
await process_cmds(mc, cmds, json_output)
24332443

24342444
def version():
24352445
print (f"meshcore-cli: command line interface to MeshCore companion radios {VERSION}")

0 commit comments

Comments
 (0)