This repository has been archived by the owner on Jul 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEasyGit.cpp
122 lines (110 loc) · 3.96 KB
/
EasyGit.cpp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* MIT License
#
# Copyright (c) 2020 Ferhat Geçdoğan All Rights Reserved.
# Distributed under the terms of the MIT License.
#
# */
#include <iostream>
#include "EasyGit.hpp"
#include "Library/Colorized.hpp"
#include "Library/FileSystemPlusPlus.h"
#define READY 0
std::string Arg;
const std::string compilation_time = __TIME__;
std::string ftime(compilation_time); // Convert
std::string EraseAllSubString(std::string & mainString, const std::string & erase) {
size_t pos = std::string::npos;
while((pos = mainString.find(erase)) != std::string::npos) {
mainString.erase(pos, erase.length());
}
return mainString;
}
std::string VersionGenerator() {
return "easygitv" + EraseAllSubString(ftime, ":");
};
void
EasyGit::HelpFunction() {
colorized::PrintWith(colorized::Colorize(BOLD, MAGENTA).c_str(), "Fegeya EasyGit Functions:\n");
colorized::PrintWith(colorized::Colorize(BOLD, CYAN).c_str(), "easygit --easy\n");
colorized::PrintWith(colorized::Colorize(BOLD, BLUE).c_str(), "easygit --license\n");
}
void SystemIntegration(std::string sys) {
system(sys.c_str());
}
void
EasyGit::Easy(std::string easy) {
}
int main(int argc, char** argv) {
EasyGit git;
if(argc > 1) {
for(int i = 1; i < argc; i++) {
std::string arg(argv[i]);
if(arg.substr(0, 2) == "--") {
if(arg == "--easy") {
Arg.erase();
std::getline(std::cin, Arg);
SystemIntegration("git init");
SystemIntegration("git add .");
SystemIntegration("git commit -m \"First Commit\"");
SystemIntegration("git remote add origin " + Arg);
SystemIntegration("git pull origin master");
SystemIntegration("git push -f origin master");
} else if(arg == "--license") {
Arg.erase();
printf("Which License? (e.g. : MIT, Apache2.0, GPLv3)");
std::getline(std::cin, Arg);
if(Arg == "MIT") {
std::string year;
std::string name;
printf("Year :");
std::getline(std::cin, year);
printf("Author name : ");
std::getline(std::cin, name);
fsplusplus::CreateFileWithoutAppend("LICENSE", git.MITLicense(year, name));
} else if(Arg == "Apache2.0") {
std::string year;
std::string name;
printf("Year :");
std::getline(std::cin, year);
printf("Author name : ");
std::getline(std::cin, name);
fsplusplus::CreateFileWithoutAppend("LICENSE", git.Apachev2License(year, name));
} else if(Arg == "GPLv3") {
std::string year;
std::string name;
printf("Year :");
std::getline(std::cin, year);
printf("Author name : ");
std::getline(std::cin, name);
fsplusplus::CreateFileWithoutAppend("LICENSE", git.GPLv3License(year, name));
}
} else if(arg == "--help") {
git.HelpFunction();
exit(EXIT_SUCCESS);
} else if(arg == "--h") {
git.HelpFunction();
exit(EXIT_SUCCESS);
} else if(arg == "--version") {
colorized::PrintWith(colorized::Colorize(BOLD, MAGENTA).c_str(), EASYGIT_VERSION);
colorized::PrintWith(colorized::Colorize(BOLD, MAGENTA).c_str(), "-");
colorized::PrintWith(colorized::Colorize(BOLD, BLUE).c_str(), EASYGIT_STATUS);
colorized::PrintWith(colorized::Colorize(BOLD, MAGENTA).c_str(), "-");
colorized::PrintWith(colorized::Colorize(BOLD, YELLOW).c_str(), VersionGenerator().c_str());
printf("\n");
} else if(arg == "--v") {
colorized::PrintWith(colorized::Colorize(BOLD, MAGENTA).c_str(), EASYGIT_VERSION);
colorized::PrintWith(colorized::Colorize(BOLD, MAGENTA).c_str(), "-");
colorized::PrintWith(colorized::Colorize(BOLD, BLUE).c_str(), EASYGIT_STATUS);
colorized::PrintWith(colorized::Colorize(BOLD, MAGENTA).c_str(), "-");
colorized::PrintWith(colorized::Colorize(BOLD, YELLOW).c_str(), VersionGenerator().c_str());
printf("\n");
}
} else {
git.HelpFunction();
}
}
} else {
git.HelpFunction();
}
return READY;
}