refactor: extract URL opening functionality into dedicated io.offer_url method

This commit is contained in:
Paul Gauthier (aider) 2024-11-07 10:26:33 -08:00
parent 2cf93ccb54
commit 0368c3fae9
2 changed files with 10 additions and 3 deletions

View file

@ -485,6 +485,15 @@ class InputOutput:
hist = "\n" + content.strip() + "\n\n"
self.append_chat_history(hist)
def offer_url(self, url, prompt="Open URL for more info?"):
"""Offer to open a URL in the browser, returns True if opened."""
if url.rstrip(".',\"") in self.never_prompts:
return False
if self.confirm_ask(prompt, subject=url, allow_never=True):
webbrowser.open(url)
return True
return False
def confirm_ask(
self,
question,