5 changed files with 50 additions and 0 deletions
Binary file not shown.
Binary file not shown.
@ -0,0 +1,9 @@ |
|||||
|
package project.command; |
||||
|
|
||||
|
import project.view.CliView; |
||||
|
|
||||
|
public interface Command { |
||||
|
String getName(); |
||||
|
String getDescription(); |
||||
|
void execute(String[] args, CliView view); |
||||
|
} |
||||
Binary file not shown.
@ -0,0 +1,41 @@ |
|||||
|
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(); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue