import command.*; import controller.CrawlerController; import repository.DataRepository; import view.ConsoleView; import java.util.Scanner; public class Main { public static void main(String[] args) { ConsoleView view = new ConsoleView(); DataRepository repository = new DataRepository(); CrawlerController controller = new CrawlerController(view, repository); controller.start(); Scanner scanner = new Scanner(System.in); while (controller.isRunning()) { controller.showMenu(); try { String input = scanner.nextLine().trim().toLowerCase(); Command command = parseCommand(input); if (command != null) { command.execute(controller); } else { view.showError("Invalid input"); } } catch (Exception e) { view.showError("Error: " + e.getMessage()); e.printStackTrace(); } } scanner.close(); } private static Command parseCommand(String input) { if (input.equals("1")) return new CrawlCommand(1); if (input.equals("2")) return new CrawlCommand(2); if (input.equals("3")) return new CrawlCommand(3); if (input.equals("4")) return new CrawlCommand(4); if (input.equals("5")) return new ListCommand(); if (input.equals("6")) return new Command() { public void execute(CrawlerController controller) { controller.generateVisualizations(); } }; if (input.equals("h") || input.equals("help")) return new HelpCommand(); if (input.equals("0")) return new ExitCommand(); return null; } }