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
```
This commit is contained in:
Paul Gauthier 2023-05-10 15:53:58 -07:00
parent b66ac52388
commit 623d36d831

View file

@ -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"