From 623d36d831eeaf51375b7a62bd40af2a92173c40 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 10 May 2023 15:53:58 -0700 Subject: [PATCH] aider: Implemented `get_command_completions` method to call the corresponding `cmd_{cmd_name}_completions` method if it exists and return its result, otherwise return None. # Context: USER: implement get_command_completions. it should look for f"cmd_{cmd_name}_completions" and call that function and return the results. if the functionn isn't found return None. ASSISTANT: To implement the `get_command_completions` method, we will call the corresponding `cmd_{cmd_name}_completions` method if it exists and return its result. If the method is not found, we will return None. Here's the updated code for `aider/commands.py`: ```python aider/commands.py <<<<<<< ORIGINAL def get_command_completions(self, cmd_name): pass ======= def get_command_completions(self, cmd_name): cmd_completions_method_name = f"cmd_{cmd_name}_completions" cmd_completions_method = getattr(self, cmd_completions_method_name, None) if cmd_completions_method: return cmd_completions_method() else: return None >>>>>>> UPDATED ``` --- aider/commands.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aider/commands.py b/aider/commands.py index 7d4ce4446..91dfa0129 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -35,6 +35,13 @@ class Commands: else: self.console.print(f"Error: Command {cmd_name} not found.") + def get_command_completions(self, cmd_name): + cmd_completions_method_name = f"cmd_{cmd_name}_completions" + cmd_completions_method = getattr(self, cmd_completions_method_name, None) + if cmd_completions_method: + return cmd_completions_method() + else: + return None def run(self, inp): words = inp.strip().split() if not words: @@ -137,6 +144,9 @@ class Commands: else: self.console.print(f"[red]{matched_file} is already in the chat") + def cmd_add_completions(self): + return self.coder.get_active_files() + def cmd_drop(self, args): "Remove matching files from the chat"