-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
44 lines (39 loc) · 1.52 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.io.*;
import java.util.*;
public class Main {
/**
* @param args the only expected argument is the path to the root directory
*/
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("wrong number of arguments");
} else {
File f = new File(args[0]);
if (!f.exists()) {
System.out.println(args[0] + " does not exist");
} else if (!f.isDirectory()) {
System.out.println(args[0] + " is not a directory");
} else if (!f.canWrite()) {
System.out.println(args[0] + " is read-only");
} else {
VCS vcs = new VCS(args[0]);
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.print("> ");
Command cmd = Command.parse(scanner.nextLine(), vcs);
if (cmd != null) {
String information = "";
if(cmd instanceof Modifying) {
information = ((Modifying) cmd).getInformation();
}
if(information != "") {
System.out.println("This command does the following modifying operations:");
System.out.println(information);
}
cmd.execute();
}
}
}
}
}
}