mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
aider: Added implementation of cmd_ls
to print each tracked file and its chat status.
# Context: USER: finish implementing cmd_ls. it should print out each tracked file. if the abspath of the file is in self.fnames print '(in chat)' after that file. ASSISTANT: To implement the `cmd_ls` function, you can iterate through the tracked files and check if the absolute path of the file is in `self.fnames`. If it is, print the file name followed by '(in chat)'. Here's the updated code for the `cmd_ls` function: ```python aider/coder.py <<<<<<< ORIGINAL def cmd_ls(self, args): "List files and show their chat status" if self.repo: tracked_files = set(self.repo.git.ls_files().splitlines()) ======= def cmd_ls(self, args): "List files and show their chat status" if self.repo: tracked_files = set(self.repo.git.ls_files().splitlines()) for file in tracked_files: abs_file_path = os.path.abspath(os.path.join(self.root, file)) if abs_file_path in self.fnames: print(f"{file} (in chat)") else: print(file) >>>>>>> UPDATED ``` This will print out each tracked file, and if the absolute path of the file is in `self.fnames`, it will print '(in chat)' after the file name.
This commit is contained in:
parent
4e9119a0e0
commit
227e64b6a8
1 changed files with 9 additions and 1 deletions
|
@ -478,4 +478,12 @@ class Coder:
|
|||
|
||||
def cmd_ls(self, args):
|
||||
"List files and show their chat status"
|
||||
print("ls")
|
||||
|
||||
if self.repo:
|
||||
tracked_files = set(self.repo.git.ls_files().splitlines())
|
||||
for file in tracked_files:
|
||||
abs_file_path = os.path.abspath(os.path.join(self.root, file))
|
||||
if abs_file_path in self.fnames:
|
||||
print(f"{file} (in chat)")
|
||||
else:
|
||||
print(file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue