You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
package project;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Scanner;
|
|
import project.command.*;
|
|
import project.controller.CrawlController;
|
|
import project.view.CliView;
|
|
|
|
public class Main {
|
|
private static boolean running = true;
|
|
|
|
public static void main(String[] args) {
|
|
CliView view = new CliView();
|
|
CrawlController controller = new CrawlController();
|
|
|
|
Map<String, Command> commands = new HashMap<>();
|
|
commands.put("crawl", new CrawlCommand(controller, view));
|
|
commands.put("help", new HelpCommand(commands));
|
|
commands.put("exit", new ExitCommand(() -> running = false));
|
|
|
|
CommandExecutor executor = new CommandExecutor(commands, view);
|
|
|
|
if (args.length > 0) {
|
|
String input = String.join(" ", args);
|
|
executor.execute(input);
|
|
return;
|
|
}
|
|
|
|
view.printBanner();
|
|
view.printHelp(commands);
|
|
|
|
Scanner scanner = new Scanner(System.in);
|
|
while (running) {
|
|
view.printPrompt();
|
|
String input = scanner.nextLine();
|
|
executor.execute(input);
|
|
}
|
|
scanner.close();
|
|
}
|
|
}
|