From 2406de41ce9d0a1404cbf4e55537e3f720f37f23 Mon Sep 17 00:00:00 2001 From: Vegard Bieker Matthey Date: Sat, 30 May 2026 22:49:36 +0200 Subject: [PATCH] InteractiveItemSelector: Allow quitting with 'q' --- src/libdib/repl.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libdib/repl.py b/src/libdib/repl.py index 1b5c8a8..2642505 100644 --- a/src/libdib/repl.py +++ b/src/libdib/repl.py @@ -34,7 +34,6 @@ def format_date(date: datetime) -> str: InteractiveItemSelectorType = TypeVar("InteractiveItemSelectorType") -# TODO: We need a way to exit the selector without selecting an item, maybe by entering 'q' or something. class InteractiveItemSelector(Generic[InteractiveItemSelectorType], Cmd): sql_session: Session execute_selection: Callable[[Session, type, str], list[Any]] @@ -92,6 +91,9 @@ class InteractiveItemSelector(Generic[InteractiveItemSelectorType], Cmd): print(f"Error executing selection: {e}") if len(result) != 1: + if arg == "q": + self.result = None + return True print(f"No such {self.cls.__name__} found: {arg}") return