mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
Add support for multiple file arguments using --file
This commit is contained in:
parent
7cf4db58d9
commit
28772ddc03
2 changed files with 11 additions and 7 deletions
|
@ -31,6 +31,9 @@ def get_parser(default_config_files, git_root):
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"files", metavar="FILE", nargs="*", help="files to edit with an LLM (optional)"
|
"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(
|
group.add_argument(
|
||||||
"--openai-api-key",
|
"--openai-api-key",
|
||||||
metavar="OPENAI_API_KEY",
|
metavar="OPENAI_API_KEY",
|
||||||
|
|
|
@ -372,10 +372,11 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
for fname in loaded_dotenvs:
|
for fname in loaded_dotenvs:
|
||||||
io.tool_output(f"Loaded {fname}")
|
io.tool_output(f"Loaded {fname}")
|
||||||
|
|
||||||
fnames = [str(Path(fn).resolve()) for fn in args.files]
|
all_files = args.files + (args.file or [])
|
||||||
if len(args.files) > 1:
|
fnames = [str(Path(fn).resolve()) for fn in all_files]
|
||||||
|
if len(all_files) > 1:
|
||||||
good = True
|
good = True
|
||||||
for fname in args.files:
|
for fname in all_files:
|
||||||
if Path(fname).is_dir():
|
if Path(fname).is_dir():
|
||||||
io.tool_error(f"{fname} is a directory, not provided alone.")
|
io.tool_error(f"{fname} is a directory, not provided alone.")
|
||||||
good = False
|
good = False
|
||||||
|
@ -386,13 +387,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
git_dname = None
|
git_dname = None
|
||||||
if len(args.files) == 1:
|
if len(all_files) == 1:
|
||||||
if Path(args.files[0]).is_dir():
|
if Path(all_files[0]).is_dir():
|
||||||
if args.git:
|
if args.git:
|
||||||
git_dname = str(Path(args.files[0]).resolve())
|
git_dname = str(Path(all_files[0]).resolve())
|
||||||
fnames = []
|
fnames = []
|
||||||
else:
|
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
|
return 1
|
||||||
|
|
||||||
# We can't know the git repo for sure until after parsing the args.
|
# We can't know the git repo for sure until after parsing the args.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue