forked from YoussefAhmed256/gitlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
55 lines (54 loc) · 1.59 KB
/
Main.java
File metadata and controls
55 lines (54 loc) · 1.59 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
package gitlet;
/** Driver class for Gitlet, a subset of the Git version-control system.
* @author TODO
*/
public class Main {
public static void main(String[] args) {
Repository repo = new Repository();
// TODO: what if args is empty?
String firstArg = args[0];
switch(firstArg) {
case "init":
repo.init();
break;
case "add":
repo.add(args[1]);
break;
case "commit":
repo.commit(args[1]);
break;
case "merge":
repo.merge(args[1]);
break;
case "branch":
repo.branch(args[1]);
break;
case "rm":
repo.rm(args[1]);
break;
case "rm-branch":
repo.rmBranch(args[1]);
break;
case "checkout":
if (args.length == 1)
repo.checkoutBranch(args[0]);
else if(args.length == 3 && args[1] == "--")
repo.checkoutFile(args[2]);
else if (args.length == 4 && args[2] == "--")
repo.checkoutFile(args[3], args[1]);
break;
case "log":
repo.log();
break;
case "global-log" :
repo.globalLog();
break;
case "find":
repo.find(args[1]);
break;
case "status":
repo.status();
break;
}
}
}