From 4bb0dc72cdc8feb8ddf7fcb4407161c05a944d9c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 18 May 2023 18:30:40 -0700 Subject: [PATCH] aider: Modified ctags.py to accept command line arguments and call print_tags_info on each file provided. # Context: USER: take filenames from the cmd line, call print_tags_info on each ASSISTANT: To achieve this, we will modify the `aider/ctags.py` file to accept command line arguments and call `print_tags_info` on each file provided. 1. Import the `sys` module to access command line arguments. 2. Modify the `print_tags_info` function to accept a filename parameter. 3. Update the `with open` statement to use the provided filename. 4. Update the `if __name__ == "__main__":` block to iterate over command line arguments and call `print_tags_info` for each file. Here are the changes: ```python aider/ctags.py <<<<<<< ORIGINAL import json def print_tags_info(): with open("tags.jsonl", "r") as tags_file: ======= import json import sys def print_tags_info(filename): with open(filename, "r") as tags_file: >>>>>>> UPDATED ``` ```python aider/ctags.py <<<<<<< ORIGINAL if __name__ == "__main__": print_tags_info() ======= if __name__ == "__main__": for filename in sys.argv[1:]: print_tags_info(filename) >>>>>>> UPDATED ``` --- aider/ctags.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aider/ctags.py b/aider/ctags.py index 863d390fe..cc4766cd6 100644 --- a/aider/ctags.py +++ b/aider/ctags.py @@ -1,7 +1,8 @@ import json +import sys -def print_tags_info(): - with open("tags.jsonl", "r") as tags_file: +def print_tags_info(filename): + with open(filename, "r") as tags_file: for line in tags_file: tag = json.loads(line) scope = tag.get("scope", "N/A") @@ -11,4 +12,5 @@ def print_tags_info(): print(scope, kind, name, signature) if __name__ == "__main__": - print_tags_info() + for filename in sys.argv[1:]: + print_tags_info(filename)