From 0dd35cdaee987bb5c07b5527dc67a9c703fc78f8 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 11 May 2023 17:41:23 -0700 Subject: [PATCH] aider: Added a new argument `--yes` to always say yes to every confirmation and passed it to the `Coder` class. # Context: USER: add a new arg --yes without env. pass it to Coder and store in self.yes. "Always say yes to every confirmation" ASSISTANT: To add a new argument `--yes` and pass it to the `Coder` class, we need to make changes in `aider/main.py` and `aider/coder.py`. In `aider/main.py`, add the new argument `--yes` to the argument parser and pass it to the `Coder` class. ```python aider/main.py <<<<<<< ORIGINAL 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))), ) ======= 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))), ) parser.add_argument( "--yes", action="store_true", help="Always say yes to every confirmation", ) >>>>>>> UPDATED ``` ```python aider/main.py <<<<<<< ORIGINAL coder = Coder(args.model, fnames, pretty, args.history_file, args.show_diffs, args.auto_commits) ======= coder = Coder(args.model, fnames, pretty, args.history_file, args.show_diffs, args.auto_commits, args.yes) >>>>>>> UPDATED ``` In `aider/coder.py`, add the `yes` parameter to the `Coder` class and store it in `self.yes`. ```python aider/coder.py <<<<<<< ORIGINAL def __init__(self, main_model, fnames, pretty, history_file, show_diffs, auto_commits): ======= def __init__(self, main_model, fnames, pretty, history_file, show_diffs, auto_commits, yes): >>>>>>> UPDATED ``` ```python aider/coder.py <<<<<<< ORIGINAL self.show_diffs = show_diffs ======= self.show_diffs = show_diffs self.yes = yes >>>>>>> UPDATED ``` Now, the `--yes` argument is added and passed to the `Coder` class. You can use `self.yes` in the `Coder` class to determine if the user wants to always say yes to every confirmation. --- aider/coder.py | 3 ++- aider/main.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 67fbbeb39..082dbabfa 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -33,7 +33,7 @@ class Coder: repo = None last_aider_commit_hash = None - def __init__(self, main_model, fnames, pretty, history_file, show_diffs, auto_commits): + def __init__(self, main_model, fnames, pretty, history_file, show_diffs, auto_commits, yes): self.history_file = history_file self.auto_commits = auto_commits @@ -57,6 +57,7 @@ class Coder: self.pretty = pretty self.show_diffs = show_diffs + self.yes = yes def find_common_root(self): if self.abs_fnames: diff --git a/aider/main.py b/aider/main.py index 78ed5f8cc..629db16d1 100644 --- a/aider/main.py +++ b/aider/main.py @@ -62,11 +62,16 @@ def main(argv=[]): 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))), ) + parser.add_argument( + "--yes", + action="store_true", + help="Always say yes to every confirmation", + ) args = parser.parse_args(argv) fnames = args.files pretty = args.pretty - coder = Coder(args.model, fnames, pretty, args.history_file, args.show_diffs, args.auto_commits) + coder = Coder(args.model, fnames, pretty, args.history_file, args.show_diffs, args.auto_commits, args.yes) coder.commit(ask=True, prefix="wip: ", which="repo_files") if args.apply: