Skip to content

Commit 8349b27

Browse files
committed
some configuration on prompt and new defaults for windows and macs
1 parent ed1c2ad commit 8349b27

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
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.2.9"
7+
version = "1.2.10"
88
authors = [
99
{ name="Florent de Lamotte", email="[email protected]" },
1010
]

src/meshcore_cli/meshcore_cli.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
import asyncio
7-
import os, sys, io
7+
import os, sys, io, platform
88
import time, datetime
99
import getopt, json, shlex, re
1010
import logging
@@ -33,7 +33,7 @@
3333
from meshcore import MeshCore, EventType, logger
3434

3535
# Version
36-
VERSION = "v1.2.8"
36+
VERSION = "v1.2.10"
3737

3838
# default ble address is stored in a config file
3939
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -76,6 +76,15 @@
7676
ANSI_YELLOW = "\033[0;33m"
7777
ANSI_BYELLOW = "\033[1;33m"
7878

79+
#Unicode chars
80+
# some possible symbols for prompts 🭬🬛🬗🭬🬛🬃🬗🭬🬛🬃🬗🬏🭀🭋🭨🮋
81+
ARROW_TAIL = "🭨"
82+
ARROW_HEAD = "🭬"
83+
84+
if platform.system() == 'Windows' or platform.system() == 'Darwin':
85+
ARROW_TAIL = ""
86+
ARROW_HEAD = " "
87+
7988
def escape_ansi(line):
8089
ansi_escape = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]')
8190
return ansi_escape.sub('', line)
@@ -762,7 +771,6 @@ def _(event):
762771
else:
763772
prompt = f"{ANSI_INVERT}"
764773

765-
# some possible symbols for prompts 🭬🬛🬗🭬🬛🬃🬗🭬🬛🬃🬗🬏🭀🭋🭨🮋
766774
if print_name or contact is None :
767775
prompt = prompt + f"{ANSI_BGRAY}"
768776
prompt = prompt + f"{mc.self_info['name']}"
@@ -772,7 +780,7 @@ def _(event):
772780
if classic :
773781
prompt = prompt + " > "
774782
else :
775-
prompt = prompt + f"{ANSI_NORMAL}🭬{ANSI_INVERT}"
783+
prompt = prompt + f"{ANSI_NORMAL}{ARROW_HEAD}{ANSI_INVERT}"
776784

777785
if not contact is None :
778786
if not last_ack:
@@ -793,7 +801,7 @@ def _(event):
793801
prompt = prompt + f"{ANSI_INVERT}"
794802

795803
if print_name and not classic :
796-
prompt = prompt + f"{ANSI_NORMAL}🭨{ANSI_INVERT}"
804+
prompt = prompt + f"{ANSI_NORMAL}{ARROW_TAIL}{ANSI_INVERT}"
797805

798806
prompt = prompt + f"{contact['adv_name']}"
799807
if contact["type"] == 0 or contact["out_path_len"]==-1:
@@ -810,7 +818,7 @@ def _(event):
810818
if classic :
811819
prompt = prompt + f"{ANSI_NORMAL} > "
812820
else:
813-
prompt = prompt + f"{ANSI_NORMAL}🭬"
821+
prompt = prompt + f"{ANSI_NORMAL}{ARROW_HEAD}"
814822

815823
prompt = prompt + f"{ANSI_END}"
816824

@@ -1604,6 +1612,7 @@ async def print_disc_trace_to (mc, contact):
16041612

16051613
async def next_cmd(mc, cmds, json_output=False):
16061614
""" process next command """
1615+
global ARROW_TAIL, ARROW_HEAD
16071616
try :
16081617
argnum = 0
16091618

@@ -1737,6 +1746,10 @@ async def next_cmd(mc, cmds, json_output=False):
17371746
interactive_loop.classic = (cmds[2] == "on")
17381747
if json_output :
17391748
print(json.dumps({"cmd" : cmds[1], "param" : cmds[2]}))
1749+
case "arrow_tail":
1750+
ARROW_TAIL = cmds[2]
1751+
case "arrow_head":
1752+
ARROW_HEAD = cmds[2]
17401753
case "color" :
17411754
process_event_message.color = (cmds[2] == "on")
17421755
if json_output :
@@ -2344,7 +2357,7 @@ async def next_cmd(mc, cmds, json_output=False):
23442357
if classic :
23452358
print("→",end="")
23462359
else :
2347-
print(f"{ANSI_NORMAL}🭬",end="")
2360+
print(f"{ANSI_NORMAL}{ARROW_HEAD}",end="")
23482361
print(ANSI_END, end="")
23492362
if "hash" in t:
23502363
print(f"[{t['hash']}]",end="")

0 commit comments

Comments
 (0)