mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00

# Context: USER: reverse the logic of the --no-aut-commits variable, so it's storing to an "auto_commits" var. default is true. env is AUTO_COMMITS. but keep the switch as --no-auto-commits ASSISTANT: To reverse the logic of the `--no-auto-commits` variable, we need to change the variable name to `auto_commits`, set its default value to `True`, and update the environment variable to `AUTO_COMMITS`. Please provide the contents of the file where this variable is defined, so I can suggest the necessary changes. USER: Please note that I shared content of these additional files: aider/main.py ASSISTANT: I apologize for the oversight. Here are the changes to reverse the logic of the `--no-auto-commits` variable in the `aider/main.py` file: ```python aider/main.py <<<<<<< ORIGINAL parser.add_argument( "--no-auto-commits", action="store_true", help=f"Do not automatically commit changes (default: False, ${env_prefix}NO_AUTO_COMMITS)", default=bool(int(os.environ.get(f"{env_prefix}NO_AUTO_COMMITS", 0))), ) ======= parser.add_argument( "--no-auto-commits", action="store_false", dest="auto_commits", help=f"Do not automatically commit changes (default: True, ${env_prefix}AUTO_COMMITS)", default=bool(int(os.environ.get(f"{env_prefix}AUTO_COMMITS", 1))), ) >>>>>>> UPDATED ``` This change will store the value of the `--no-auto-commits` flag in the `auto_commits` variable, with a default value of `True`. The environment variable is also updated to `AUTO_COMMITS`.
82 lines
2.5 KiB
Python
82 lines
2.5 KiB
Python
import os
|
|
import sys
|
|
import argparse
|
|
from dotenv import load_dotenv
|
|
from aider.coder import Coder
|
|
|
|
|
|
def main():
|
|
load_dotenv()
|
|
env_prefix = "AIDER_"
|
|
parser = argparse.ArgumentParser(
|
|
description="aider - chat with GPT about your code"
|
|
)
|
|
parser.add_argument(
|
|
"files",
|
|
metavar="FILE",
|
|
nargs="*",
|
|
help="a list of source code files (optional)",
|
|
)
|
|
parser.add_argument(
|
|
"--history-file",
|
|
metavar="HISTORY_FILE",
|
|
default=os.environ.get(f"{env_prefix}HISTORY_FILE", ".aider.history"),
|
|
help=f"Specify the chat input history file (default: .aider.history, ${env_prefix}HISTORY_FILE)",
|
|
)
|
|
parser.add_argument(
|
|
"--model",
|
|
metavar="MODEL",
|
|
default=os.environ.get(f"{env_prefix}MODEL", "gpt-4"),
|
|
help=f"Specify the model to use for the main chat (default: gpt-4, ${env_prefix}MODEL)",
|
|
)
|
|
parser.add_argument(
|
|
"-3",
|
|
action="store_const",
|
|
dest="model",
|
|
const="gpt-3.5-turbo",
|
|
help="Use gpt-3.5-turbo model for the main chat (basically won't work)",
|
|
)
|
|
parser.add_argument(
|
|
"--no-pretty",
|
|
action="store_false",
|
|
dest="pretty",
|
|
help=f"Disable pretty, colorized output (${env_prefix}PRETTY)",
|
|
default=bool(int(os.environ.get(f"{env_prefix}PRETTY", 1))),
|
|
)
|
|
parser.add_argument(
|
|
"--apply",
|
|
metavar="FILE",
|
|
help="Apply the changes from the given file instead of running the chat (debug)",
|
|
)
|
|
parser.add_argument(
|
|
"--no-auto-commits",
|
|
action="store_false",
|
|
dest="auto_commits",
|
|
help=f"Do not automatically commit changes (default: True, ${env_prefix}AUTO_COMMITS)",
|
|
default=bool(int(os.environ.get(f"{env_prefix}AUTO_COMMITS", 1))),
|
|
)
|
|
parser.add_argument(
|
|
"--show-diffs",
|
|
action="store_true",
|
|
help=f"Show diffs when committing changes (default: False, ${env_prefix}SHOW_DIFFS)",
|
|
default=bool(int(os.environ.get(f"{env_prefix}SHOW_DIFFS", 0))),
|
|
)
|
|
args = parser.parse_args()
|
|
fnames = args.files
|
|
pretty = args.pretty
|
|
|
|
coder = Coder(args.model, fnames, pretty, args.history_file, args.show_diffs)
|
|
coder.commit(ask=True, prefix="wip: ", which="repo_files")
|
|
|
|
if args.apply:
|
|
with open(args.apply, "r") as f:
|
|
content = f.read()
|
|
coder.update_files(content, inp="")
|
|
return
|
|
|
|
coder.run()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
status = main()
|
|
sys.exit(status)
|