3333from meshcore import MeshCore , EventType , logger
3434
3535# Version
36- VERSION = "v1.1.41 "
36+ VERSION = "v1.2.0 "
3737
3838# default ble address is stored in a config file
3939MCCLI_CONFIG_DIR = str (Path .home ()) + "/.config/meshcore/"
@@ -307,11 +307,22 @@ async def subscribe_to_msgs(mc, json_output=False, above=False):
307307 await mc .start_auto_message_fetching ()
308308
309309# redefine get_completion to let user put symbols in first item
310+ # and handle navigating in path ...
310311class MyNestedCompleter (NestedCompleter ):
311312 def get_completions ( self , document , complete_event ):
312- if not " " in document .text_before_cursor .lstrip ():
313+ txt = document .text_before_cursor .lstrip ()
314+ if not " " in txt :
315+ if txt != "" and txt [0 ] == "/" and txt .count ("/" ) == 1 :
316+ opts = []
317+ for k in self .options .keys ():
318+ if k [0 ] == "/" :
319+ v = "/" + k .split ("/" )[1 ] + ("/" if k .count ("/" ) == 2 else "" )
320+ if v not in opts :
321+ opts .append (v )
322+ else :
323+ opts = self .options .keys ()
313324 completer = WordCompleter (
314- list ( self . options . keys ()) , ignore_case = self .ignore_case ,
325+ opts , ignore_case = self .ignore_case ,
315326 pattern = re .compile (r"([a-zA-Z0-9_\\/]+|[^a-zA-Z0-9_\s]+)" ))
316327 yield from completer .get_completions (document , complete_event )
317328 else : # normal behavior for remainder
@@ -566,16 +577,36 @@ def make_completion_dict(contacts, pending={}, to=None, channels=None):
566577 completion_list .update ({
567578 "send" : None ,
568579 })
569-
570580 if to ['type' ] == 1 :
571581 completion_list .update (client_completion_list )
572-
573- if to ['type' ] > 1 : # repeaters and room servers
582+ if to ['type' ] == 2 or to ['type' ] == 3 : # repeaters and room servers
574583 completion_list .update (repeater_completion_list )
575-
576584 if (to ['type' ] == 4 ) : #specific to sensors
577585 completion_list .update (sensor_completion_list )
578586
587+ slash_root_completion_list = {}
588+ for k ,v in root_completion_list .items ():
589+ slash_root_completion_list ["/" + k ]= v
590+
591+ completion_list .update (slash_root_completion_list )
592+
593+ slash_contacts_completion_list = {}
594+ for k ,v in contacts .items ():
595+ d = {}
596+ if v ["type" ] == 1 :
597+ l = client_completion_list
598+ elif v ["type" ] == 2 or v ["type" ] == 3 :
599+ l = repeater_completion_list
600+ elif v ["type" ] == 4 :
601+ l = sensor_completion_list
602+
603+ for kk , vv in l .items ():
604+ d ["/" + v ["adv_name" ] + "/" + kk ] = vv
605+
606+ slash_contacts_completion_list .update (d )
607+
608+ completion_list .update (slash_contacts_completion_list )
609+
579610 completion_list .update ({
580611 "script" : None ,
581612 "quit" : None
@@ -700,6 +731,10 @@ def _(event):
700731 pass
701732
702733 # raw meshcli command as on command line
734+ elif line .startswith ("$" ) :
735+ args = shlex .split (line [1 :])
736+ await process_cmds (mc , args )
737+
703738 elif line .startswith ("/" ) :
704739 path = line .split (" " , 1 )[0 ]
705740 if path .count ("/" ) == 1 :
@@ -713,11 +748,10 @@ def _(event):
713748 print (f"{ contact_name } is not a contact" )
714749 else :
715750 if not await process_contact_chat_line (mc , tct , cmdline ):
716- print (f"{ cmdline } not found for { contact_name } " )
717-
718- elif line .startswith ("$" ) :
719- args = shlex .split (line [1 :])
720- await process_cmds (mc , args )
751+ if tct ["type" ] == 1 :
752+ last_ack = await msg_ack (mc , tct , cmdline )
753+ else :
754+ await process_cmds (mc , ["cmd" , tct ["adv_name" ], cmdline ])
721755
722756 elif line .startswith ("to " ) : # dest
723757 dest = line [3 :]
0 commit comments