From 000fd853d248fd3e92dc00f6338e1f9d46fbff86 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 26 May 2023 16:29:29 -0700 Subject: [PATCH] aider: Added --pretty argument with store_true action to support pretty: true in conf yaml. # Context: USER: does configargparse support bool args like `--thing' and `--no-thing` ASSISTANT: Yes, `configargparse` supports boolean arguments. You can create a boolean argument with `--thing` and `--no-thing` by using the `action` parameter with values `"store_true"` and `"store_false"` respectively. Here's an example: ```python parser.add_argument( "--thing", action="store_true", default=False, help="Enable thing (default: False)", ) parser.add_argument( "--no-thing", action="store_false", dest="thing", help="Disable thing (default: True)", ) ``` In this example, the `--thing` argument will set the `thing` variable to `True`, and the `--no-thing` argument will set the `thing` variable to `False`. USER: i have --no-pretty, but if I add `pretty: true` to the conf yaml, it throws error: aider: error: unrecognized arguments: --pretty=False ASSISTANT: The error occurs because the `--pretty` argument is not explicitly defined in the parser. To fix this, you can add a `--pretty` argument with the `store_true` action. Here's how to modify the `aider/main.py` file: ```python aider/main.py <<<<<<< ORIGINAL parser.add_argument( "--no-pretty", action="store_false", dest="pretty", env_var=f"{env_prefix}PRETTY", help="Disable pretty, colorized output", default=True, ) ======= parser.add_argument( "--pretty", action="store_true", default=True, help="Enable pretty, colorized output (default: True)", ) parser.add_argument( "--no-pretty", action="store_false", dest="pretty", env_var=f"{env_prefix}PRETTY", help="Disable pretty, colorized output", ) >>>>>>> UPDATED ``` Now, you can use `pretty: true` in your configuration file without any issues. --- aider/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/aider/main.py b/aider/main.py index e8a7a794f..c5ade758f 100644 --- a/aider/main.py +++ b/aider/main.py @@ -81,13 +81,19 @@ def main(args=None, input=None, output=None): const="gpt-3.5-turbo", help="Use gpt-3.5-turbo model for the main chat (not advised)", ) + parser.add_argument( + "--pretty", + action="store_true", + default=True, + help="Enable pretty, colorized output (default: True)", + ) + parser.add_argument( "--no-pretty", action="store_false", dest="pretty", env_var=f"{env_prefix}PRETTY", help="Disable pretty, colorized output", - default=True, ) parser.add_argument( "--apply",