package com.crawler.command; import com.crawler.controller.CrawlerController; import com.crawler.view.ConsoleView; public class CrawlCommand implements Command { private final CrawlerController controller; private final ConsoleView view; public CrawlCommand(CrawlerController controller, ConsoleView view) { this.controller = controller; this.view = view; } @Override public void execute(String[] args) { if (args.length < 1) { view.displayError("Usage: crawl [strategy]"); return; } String url = args[0]; String strategy = args.length > 1 ? args[1] : "jsoup"; try { controller.crawl(url, strategy); } catch (Exception e) { view.displayError("Crawl failed: " + e.getMessage()); } } @Override public String getCommandName() { return "crawl"; } @Override public String getDescription() { return "Crawl a website"; } }