mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
aider: Added support for --version
flag to display the version number.
# Context: USER: should `aider --help` show the version now? ASSISTANT: Yes, with the changes you made, running `aider --help` should show the version information. However, the version will be displayed when you run `aider --version`. The `--help` output will include a line mentioning the `--version` flag, but it won't directly show the version number. USER: I ran this command: aider --version And got this output: Traceback (most recent call last): File "/Users/gauthier/Projects/aider/.venv/bin/aider", line 8, in <module> sys.exit(main()) ^^^^^^ File "/Users/gauthier/Projects/aider/aider/main.py", line 32, in main parser = configargparse.ArgumentParser( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gauthier/Projects/aider/.venv/lib/python3.11/site-packages/configargparse.py", line 433, in __init__ argparse.ArgumentParser.__init__(self, *args, **kwargs) TypeError: ArgumentParser.__init__() got an unexpected keyword argument 'version' ASSISTANT: I apologize for the confusion earlier. It seems I made a mistake. `configargparse` does not have a built-in `version` parameter like `argparse`. Instead, you can add a custom argument with the `--version` flag and handle it manually. Here's how you can modify your `aider/main.py` file: ```python aider/main.py <<<<<<< ORIGINAL parser = configargparse.ArgumentParser( description="aider is GPT powered coding in your terminal", add_config_file_help=True, default_config_files=default_config_files, config_file_parser_class=configargparse.YAMLConfigFileParser, auto_env_var_prefix="AIDER_", version=__version__, ) ======= parser = configargparse.ArgumentParser( description="aider is GPT powered coding in your terminal", add_config_file_help=True, default_config_files=default_config_files, config_file_parser_class=configargparse.YAMLConfigFileParser, auto_env_var_prefix="AIDER_", ) parser.add_argument( "--version", action="store_true", help="Show the version number and exit", ) >>>>>>> UPDATED ``` ```python aider/main.py <<<<<<< ORIGINAL args = parser.parse_args(args) ======= args, unknown_args = parser.parse_known_args(args) if args.version: print(f"aider version {__version__}") sys.exit(0) # Re-parse the arguments to include unknown_args args = parser.parse_args(args + unknown_args) ^C KeyboardInterrupt USER: can we add soemthing like this: parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + __version__) ASSISTANT: I apologize for the confusion earlier. It turns out that `configargparse` does support the `version` action, similar to `argparse`. You can add the `--version` argument as you suggested. Here's how you can modify your `aider/main.py` file: ```python aider/main.py <<<<<<< ORIGINAL parser = configargparse.ArgumentParser( description="aider is GPT powered coding in your terminal", add_config_file_help=True, default_config_files=default_config_files, config_file_parser_class=configargparse.YAMLConfigFileParser, auto_env_var_prefix="AIDER_", version=__version__, ) ======= parser = configargparse.ArgumentParser( description="aider is GPT powered coding in your terminal", add_config_file_help=True, default_config_files=default_config_files, config_file_parser_class=configargparse.YAMLConfigFileParser, auto_env_var_prefix="AIDER_", ) parser.add_argument( "-v", "--version", action="version", version=f"%(prog)s {__version__}", help="Show the version number and exit" ) >>>>>>> UPDATED ``` Now, running `aider --version` or `aider -v` will display the version number as expected.
This commit is contained in:
parent
cdb62c1462
commit
d8938ee033
1 changed files with 4 additions and 1 deletions
|
@ -35,7 +35,10 @@ def main(args=None, input=None, output=None):
|
|||
default_config_files=default_config_files,
|
||||
config_file_parser_class=configargparse.YAMLConfigFileParser,
|
||||
auto_env_var_prefix="AIDER_",
|
||||
version=__version__,
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-v", "--version", action="version", version=f"%(prog)s {__version__}", help="Show the version number and exit"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue