From 28772ddc03068c1caa1a95fa26431b405cf2bbed Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sun, 28 Jul 2024 20:58:46 -0300 Subject: [PATCH] Add support for multiple file arguments using --file --- aider/args.py | 3 +++ aider/main.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/aider/args.py b/aider/args.py index 1d5774f7c..d7f3475e8 100644 --- a/aider/args.py +++ b/aider/args.py @@ -31,6 +31,9 @@ def get_parser(default_config_files, git_root): group.add_argument( "files", metavar="FILE", nargs="*", help="files to edit with an LLM (optional)" ) + group.add_argument( + "--file", action="append", metavar="FILE", help="specify a file to edit (can be used multiple times)" + ) group.add_argument( "--openai-api-key", metavar="OPENAI_API_KEY", diff --git a/aider/main.py b/aider/main.py index 13ee913a7..a4ac17b96 100644 --- a/aider/main.py +++ b/aider/main.py @@ -372,10 +372,11 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F for fname in loaded_dotenvs: io.tool_output(f"Loaded {fname}") - fnames = [str(Path(fn).resolve()) for fn in args.files] - if len(args.files) > 1: + all_files = args.files + (args.file or []) + fnames = [str(Path(fn).resolve()) for fn in all_files] + if len(all_files) > 1: good = True - for fname in args.files: + for fname in all_files: if Path(fname).is_dir(): io.tool_error(f"{fname} is a directory, not provided alone.") good = False @@ -386,13 +387,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F return 1 git_dname = None - if len(args.files) == 1: - if Path(args.files[0]).is_dir(): + if len(all_files) == 1: + if Path(all_files[0]).is_dir(): if args.git: - git_dname = str(Path(args.files[0]).resolve()) + git_dname = str(Path(all_files[0]).resolve()) fnames = [] else: - io.tool_error(f"{args.files[0]} is a directory, but --no-git selected.") + io.tool_error(f"{all_files[0]} is a directory, but --no-git selected.") return 1 # We can't know the git repo for sure until after parsing the args.