-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (63 loc) · 1.66 KB
/
main.cpp
File metadata and controls
76 lines (63 loc) · 1.66 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
#include "./include/commit/cat-file.h"
#include "./include/commit/commit-logs.h"
#include "./include/commit/commit.h"
#include "./include/commit/hash-blob.h"
#include "./include/commit/ls-tree.h"
#include "./include/commit/reset.h"
#include "./include/commit/tree.h"
#include "./include/init/init.h"
#include "./include/utils/remoteutils.h"
#include "./include/utils/res-args.h"
#include <iostream>
int main(int argc, char *argv[]) {
using namespace jh;
using namespace commit;
using namespace init;
auto [command, arg1, flag] = resolveCommands(argc, argv);
if (command == "cat-file") {
catFile cat_file(arg1);
cat_file.execute();
}
else if (command == "init") {
Init init(arg1.c_str());
init.execute();
}
else if (command == "hash-object") {
hashBlob blob(arg1);
blob.execute();
}
else if (command == "ls-tree") {
if (flag == "-w") {
Tree tree(arg1);
std::cout << tree.tree << std::endl;
// tree.execute();
} else {
lsTree tree(arg1);
tree.decompressFolder();
}
}
else if (command == "commit") {
Commit commit("faishal", arg1);
commit.execute();
}
else if (command == "reset") {
ResetCommit reset(arg1);
reset.execute();
}
else if (command == "log") {
commitLog logs;
logs.execute();
}
else if (command == "remote") {
if (arg1 == "add") {
std::string remoteName = argv[3];
std::string remoteUrl = argv[4];
jh::remoteUtils::setRemoteUrl(remoteName, remoteUrl);
}
else if (arg1 == "get-url") {
std::string remoteName = argv[3];
std::cout << jh::remoteUtils::getRemoteUrl(remoteName) << std::endl;
}
}
return 0;
}