From 049edbf94088e007a48a9ef6c8792d60af979caf Mon Sep 17 00:00:00 2001 From: juk0de Date: Fri, 20 Oct 2023 09:14:40 +0200 Subject: [PATCH] cmm: limited the message locations for the new cmm parameters to those that make sense --- chatmastermind/chat.py | 2 ++ chatmastermind/main.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/chatmastermind/chat.py b/chatmastermind/chat.py index 30b1af6..41a69bd 100644 --- a/chatmastermind/chat.py +++ b/chatmastermind/chat.py @@ -325,6 +325,8 @@ class ChatDB(Chat): when reading them. * 'loc': read messages from given location instead of 'db_path' """ + if loc == msg_location.MEM: + raise ChatError(f"Can't build ChatDB from message location '{loc}'") messages: list[Message] = [] if loc in [msg_location.DB, msg_location.DISK, msg_location.ALL]: messages.extend(read_dir(db_path, glob, mfilter)) diff --git a/chatmastermind/main.py b/chatmastermind/main.py index d6eb3a2..3fba60f 100755 --- a/chatmastermind/main.py +++ b/chatmastermind/main.py @@ -67,7 +67,7 @@ def create_parser() -> argparse.ArgumentParser: question_group.add_argument('-r', '--repeat', nargs='*', help='Repeat a question', metavar='MESSAGE') question_group.add_argument('-p', '--process', nargs='*', help='Process existing questions', metavar='MESSAGE') question_cmd_parser.add_argument('-l', '--location', - choices=[x.value for x in msg_location], + choices=[x.value for x in msg_location if x not in [msg_location.MEM, msg_location.DISK]], default='db', help='Use given location when building the chat history (default: \'db\')') question_cmd_parser.add_argument('-g', '--glob', help='Filter message files using the given glob pattern') @@ -94,7 +94,7 @@ def create_parser() -> argparse.ArgumentParser: hist_cmd_parser.add_argument('-d', '--tight', help='Print without message separators', action='store_true') hist_cmd_parser.add_argument('-P', '--no-paging', help='Print without paging', action='store_true') hist_cmd_parser.add_argument('-l', '--location', - choices=[x.value for x in msg_location], + choices=[x.value for x in msg_location if x not in [msg_location.MEM, msg_location.DISK]], default='db', help='Use given location when building the chat history (default: \'db\')') hist_cmd_parser.add_argument('-g', '--glob', help='Filter message files using the given glob pattern')