aider: Add print statement with upgrade command in check_version function.

# Aider chat conversation:

USER: also print the command the user should use to upgrade

ASSISTANT: To print the command the user should use to upgrade, we can add a print statement in the `check_version` function in the `aider/versioncheck.py` file. This print statement will provide the command to upgrade the `aider-chat` package using pip.

Here is the code:

```python
aider/versioncheck.py
<<<<<<< ORIGINAL
import requests
import pkg_resources
import aider

from aider.dump import dump

def check_version():
    response = requests.get('https://pypi.org/pypi/aider-chat/json')
    data = response.json()
    latest_version = data['info']['version']
    current_version = pkg_resources.get_distribution('aider-chat').version

    if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version(current_version):
        return

    print(f"Running aider version {current_version}, newer version available: {latest_version}")

if __name__ == "__main__":
    check_version()
=======
import requests
import pkg_resources
import aider

from aider.dump import dump

def check_version():
    response = requests.get('https://pypi.org/pypi/aider-chat/json')
    data = response.json()
    latest_version = data['info']['version']
    current_version = pkg_resources.get_distribution('aider-chat').version

    if pkg_resources.parse_version(latest_version) <= pkg_resources.parse_version(current_version):
        return

    print(f"Running aider version {current_version}, newer version available: {latest_version}")
    print("To upgrade, run: pip install --upgrade aider-chat")

if __name__ == "__main__":
    check_version()
>>>>>>> UPDATED
```

This will print the command `pip install --upgrade aider-chat` when a newer version is available. The user can then copy this command and run it in their terminal to upgrade the `aider-chat` package.
This commit is contained in:
Paul Gauthier 2023-07-20 08:34:54 -03:00
parent e94f85b61e
commit 4b133929c8

View file

@ -14,6 +14,7 @@ def check_version():
return
print(f"Running aider version {current_version}, newer version available: {latest_version}")
print("To upgrade, run: pip install --upgrade aider-chat")
if __name__ == "__main__":
check_version()