feat: Replace SystemPager with pypager in cmd_web

This commit is contained in:
Paul Gauthier (aider) 2024-08-09 17:17:27 -04:00
parent c290001a9f
commit 5fd864f5e9

View file

@ -120,6 +120,9 @@ class Commands:
def cmd_web(self, args):
"Scrape a webpage, convert to markdown and add to the chat"
from pypager.source import StringSource
from pypager.pager import Pager
url = args.strip()
if not url:
self.io.tool_error("Please provide a URL to scrape.")
@ -135,11 +138,14 @@ class Commands:
)
content = self.scraper.scrape(url) or ""
# if content:
# self.io.tool_output(content)
content = f"{url}:\n\n" + content
# Use pypager to show the content
source = StringSource(content)
pager = Pager()
pager.add_source(source)
pager.run()
return content
def is_command(self, inp):