mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
aider: Added functionality to cmd_add to search for files containing words in args, print matches, and add their absolute paths to self.fnames.
# Context: USER: finish implementing cmd_add. for each word in the args, find any files which contain it. print the found matches and add their abspth to self.fnames. ASSISTANT: To implement the `cmd_add` method, you can iterate through the words in the `args` and search for files containing those words. Then, print the found matches and add their absolute paths to `self.fnames`. Here's the updated code for the `cmd_add` method: ```python aider/coder.py <<<<<<< ORIGINAL def cmd_add(self, args): "Add files to the chat" files = self.get_active_files() ======= def cmd_add(self, args): "Add files to the chat" files = self.get_active_files() for word in args: matched_files = [file for file in files if word in file] for matched_file in matched_files: abs_file_path = os.path.abspath(os.path.join(self.root, matched_file)) if abs_file_path not in self.fnames: self.fnames.add(abs_file_path) self.console.print(f"[red]Added {matched_file} to the chat") else: self.console.print(f"[red]{matched_file} is already in the chat") >>>>>>> UPDATED ``` This code will search for files containing the words in `args`, print the found matches, and add their absolute paths to `self.fnames`.
This commit is contained in:
parent
aafd524cb2
commit
cbb3d4f15f
1 changed files with 9 additions and 1 deletions
|
@ -488,7 +488,15 @@ class Coder:
|
|||
"Add files to the chat"
|
||||
|
||||
files = self.get_active_files()
|
||||
|
||||
for word in args:
|
||||
matched_files = [file for file in files if word in file]
|
||||
for matched_file in matched_files:
|
||||
abs_file_path = os.path.abspath(os.path.join(self.root, matched_file))
|
||||
if abs_file_path not in self.fnames:
|
||||
self.fnames.add(abs_file_path)
|
||||
self.console.print(f"[red]Added {matched_file} to the chat")
|
||||
else:
|
||||
self.console.print(f"[red]{matched_file} is already in the chat")
|
||||
|
||||
def cmd_ls(self, args):
|
||||
"List files and show their chat status"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue