mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 09:44:59 +00:00
aider is AI pair programming in your terminal
https://aider.chat/
![]() # Context: USER: in main add a var called env_prefix="CODER_" then for every parser arg load the default from os.environ using that prefix and the uppercase, snakecase of the arg name as the env var name ASSISTANT: To add an `env_prefix` variable and load the default values for each argument from the environment variables, you can update the `main` function as follows: ```python coder.py <<<<<<< ORIGINAL def main(): parser = argparse.ArgumentParser(description="Chat with GPT about code") parser.add_argument( "files", metavar="FILE", nargs="+", help="a list of source code files" ) parser.add_argument( "-3", "--gpt-3-5-turbo", action="store_true", help="Only use gpt-3.5-turbo, not gpt-4", ) parser.add_argument( "--no-pretty", action="store_false", dest="pretty", default=True, help="Disable prettyd output of GPT responses", ) parser.add_argument( "--apply", metavar="FILE", help="Apply the changes from the given file instead of running the chat", ) parser.add_argument( "--commit", action="store_true", help="Commit dirty files without confirmation", ) ======= def main(): env_prefix = "CODER_" parser = argparse.ArgumentParser(description="Chat with GPT about code") parser.add_argument( "files", metavar="FILE", nargs="+", help="a list of source code files", default=os.environ.get(env_prefix + "FILES", "").split() ) parser.add_argument( "-3", "--gpt-3-5-turbo", action="store_true", help="Only use gpt-3.5-turbo, not gpt-4", default=bool(os.environ.get(env_prefix + "GPT_3_5_TURBO", False)) ) parser.add_argument( "--no-pretty", action="store_false", dest="pretty", default=True, help="Disable prettyd output of GPT responses", default=bool(os.environ.get(env_prefix + "NO_PRETTY", True)) ) parser.add_argument( "--apply", metavar="FILE", help="Apply the changes from the given file instead of running the chat", default=os.environ.get(env_prefix + "APPLY", None) ) parser.add_argument( "--commit", action="store_true", help="Commit dirty files without confirmation", default=bool(os.environ.get(env_prefix + "COMMIT", False)) ) >>>>>>> UPDATED ``` This change adds the `env_prefix` variable and sets the default values for each argument using the `os.environ.get()` function with the appropriate environment variable name. |
||
---|---|---|
.flake8 | ||
.pre-commit-config.yaml | ||
coder.py | ||
dump.py | ||
prompts.py |