From a6d9581e5ff6438b9533043d2c21e8487609c312 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 11 May 2023 15:41:09 -0700 Subject: [PATCH] aider: Added a `--no-auto-commits` argument and an environment variable. # Context: USER: add a --no-auto-commits arg and env var "Do not automatically commit changes" ASSISTANT: To add a `--no-auto-commits` argument and an environment variable, we will update the `aider/main.py` file. We will add a new argument to the `argparse.ArgumentParser` and use the environment variable to set its default value. ```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( "--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( "--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))), ) >>>>>>> UPDATED ``` Now, you can use the `--no-auto-commits` argument when running the script, and it will also read the `AIDER_NO_AUTO_COMMITS` environment variable to set its default value. --- aider/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/aider/main.py b/aider/main.py index 3aa2010c1..fb209d6d4 100644 --- a/aider/main.py +++ b/aider/main.py @@ -48,6 +48,12 @@ def main(): metavar="FILE", help="Apply the changes from the given file instead of running the chat (debug)", ) + 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( "--show-diffs", action="store_true",