Browse Source

上传文件至 'project'

main
wangbo 3 weeks ago
parent
commit
08be72da2e
  1. BIN
      project/202506050323-王博-期末实验报告.docx
  2. BIN
      project/Command.class
  3. 9
      project/Command.java
  4. BIN
      project/CommandExecutor.class
  5. 41
      project/Main.java

BIN
project/202506050323-王博-期末实验报告.docx

Binary file not shown.

BIN
project/Command.class

Binary file not shown.

9
project/Command.java

@ -0,0 +1,9 @@
package project.command;
import project.view.CliView;
public interface Command {
String getName();
String getDescription();
void execute(String[] args, CliView view);
}

BIN
project/CommandExecutor.class

Binary file not shown.

41
project/Main.java

@ -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…
Cancel
Save