Add --glob and --location flags to hist and question commands, to be able to specify the location and files they should use.

This commit is contained in:
Oleksandr Kozachuk
2023-10-19 16:03:51 +02:00
parent 9a493b57da
commit 114282dfd8
6 changed files with 29 additions and 5 deletions
+6 -1
View File
@@ -325,7 +325,12 @@ class ChatDB(Chat):
* 'mfilter': use with 'Message.from_file()' to filter messages
when reading them.
"""
messages = read_dir(db_path, glob, mfilter)
messages: list[Message] = []
if loc in [msg_location.DB, msg_location.DISK, msg_location.ALL]:
messages.extend(read_dir(db_path, glob, mfilter))
if loc in [msg_location.CACHE, msg_location.DISK, msg_location.ALL]:
messages.extend(read_dir(cache_path, glob, mfilter))
messages.sort(key=lambda x: x.msg_id())
return cls(messages, cache_path, db_path, mfilter, glob)
@classmethod