Skip to content

Commit ab06a08

Browse files
committed
history
1 parent 5c68b55 commit ab06a08

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/meshcore_cli/meshcore_cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
from pathlib import Path
1111
from prompt_toolkit.shortcuts import PromptSession
1212
from prompt_toolkit.completion import NestedCompleter
13+
from prompt_toolkit.history import FileHistory
1314

1415
from meshcore import TCPConnection, BLEConnection, SerialConnection
1516
from meshcore import MeshCore, EventType, logger
1617

1718
# default ble address is stored in a config file
1819
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
1920
MCCLI_ADDRESS = MCCLI_CONFIG_DIR + "default_address"
21+
MCCLI_HISTORY_FILE = MCCLI_CONFIG_DIR + "history"
2022

2123
# Fallback address if config file not found
2224
# if None or "" then a scan is performed
@@ -170,8 +172,14 @@ async def interactive_loop(mc, to=None) :
170172
"to": None,
171173
"send": None,
172174
}
175+
173176
completer = NestedCompleter.from_nested_dict(make_completion_dict(mc.contacts))
174-
session = PromptSession(completer=completer)
177+
if os.path.isdir(MCCLI_CONFIG_DIR) :
178+
our_history = FileHistory(MCCLI_HISTORY_FILE)
179+
else:
180+
our_history = None
181+
182+
session = PromptSession(completer=completer, history=our_history)
175183

176184
last_ack = True
177185
while True:

0 commit comments

Comments
 (0)