-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
86 lines (71 loc) · 2.25 KB
/
Main.java
File metadata and controls
86 lines (71 loc) · 2.25 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package gitlet;
/** Driver class for Gitlet, a subset of the Git version-control system.
* @author Matthew Koen
*/
public class Main {
/** Usage: java gitlet.Main ARGS, where ARGS contains
* <COMMAND> <OPERAND1> <OPERAND2> ...
*/
public static void main(String[] args) {
if (args.length == 0) {
System.out.print("Must have at least one argument");
return;
}
String firstArg = args[0];
switch (firstArg) {
case "init":
Repository.init();
break;
case "add":
Repository.add(args[1]);
break;
case "commit":
if ((args.length < 2) || (args[1].equals(""))) {
System.out.print("Please enter a commit message.");
break;
}
Repository.commit(args[1]);
break;
case "rm":
Repository.rm(args[1]);
break;
case "log":
Repository.log();
break;
case "global-log":
Repository.globalLog();
break;
case "find":
Repository.find(args[1]);
break;
case "status":
Repository.status();
break;
case "checkout":
if (args.length == 3) {
Repository.checkout(args[2]);
} else if (args.length == 4) {
if (!args[2].equals("--")) {
System.out.print("Incorrect operands.");
break;
}
Repository.checkout(args[3], args[1]);
} else if (args.length == 2) {
Repository.checkoutBranch(args[1]);
}
break;
case "branch":
Repository.branch(args[1]);
break;
case "rm-branch":
Repository.rmBranch(args[1]);
break;
case "reset":
break;
case "merge":
break;
default:
System.out.print("Unknown argument.");
}
}
}