This repository has been archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
208 lines (205 loc) · 5.94 KB
/
main.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cstring>
using namespace std;
class Err{
char* a;
char* d;
public:
char*& name(){
return a;
}
char*& des(){
return d;
}
}err;
#include "trim.hpp"
char type[105];
char clas[105];
char name[105];
char temp[105];
char* chu(char a[])
{
char b[1005];
char* c = new char ;
strcpy(b,a);
int ns=0,s=0;
for(int i=0;i<strlen(b);i++)
{
if(ns==1)c[s++]=b[i];
if(b[i]=='/')ns=1;
}
c[s]='\0';
return c;
}
int main(int argc, char* argv[])
{
try{
if(argv[1]==NULL){
char nameerr[]="Type";
throw nameerr;
}
system("echo ' >> Updating...' && git pull && g++ main.cpp -o LanGong && echo");
strcpy(type,argv[1]);
//strcpy(type,trim(temp));
strcpy(temp,"install");
strcpy(temp,trim(temp));
if(strcmp(type,"install")==0){
system("echo -n 'Install Packages at ' >> ~/.config/LanFilePackage.log && date -u >> ~/.config/LanFilePackage.log");
if(argv[2]==NULL){
char nameerr[]="Class";
throw nameerr;
}
if(argv[3]==NULL){
char nameerr[]="Name";
throw nameerr;
}
strcpy(clas,argv[2]);
//strcpy(clas,trim(temp));
if(strcmp(clas,"github")==0){//GitHub
printf(" Install form GitHub : \n");
strcpy(temp,argv[3]);
strcpy(name,trim(temp));
char dobash[105];
strcpy(dobash,"cd ~/LanGongFile/ && git clone https://github.com/");
strcat(dobash,name);
strcat(dobash,".git && cd ");
strcat(dobash,chu(name));
strcat(dobash," && bash before.sh");
system(dobash);
printf("\n\n Install successfully! \n");
return 0;
}
else if(strcmp(clas,"langonggit")==0){//langonggit
printf(" Install from LanGit : \n");
strcpy(name,argv[3]);
char dobash[10005];
strcpy(dobash,"cd ~/LanGongFile/ && mkdir ");
strcat(dobash,name);
strcat(dobash," && cd ");
strcat(dobash,name);
strcat(dobash," && wget https://langong-dev.github.io/doc/");
strcat(dobash,name);
strcat(dobash,".zip -o download.zip && unzip download.zip && bash before.sh");
system(dobash);
printf("\n%s\n",dobash);
printf("\n\n Install successfully! \n");
return 0;
}
else if(strcmp(clas,"langong")==0){
printf(" Install form LanGong-GitHub : \n");
strcpy(temp,argv[3]);
strcpy(name,trim(temp));
char dobash[105];
strcpy(dobash,"cd ~/LanGongFile/ && git clone https://github.com/langong-dev/");
strcat(dobash,name);
strcat(dobash,".git && cd ");
strcat(dobash,name);
strcat(dobash," && bash before.sh");
system(dobash);
printf("\n\n Install successfully! \n");
return 0;
}
else if(strcmp(clas,"git")==0){//git
printf(" Install form Git : \n\n\n");
strcpy(name,argv[3]);
char dobash[105];
strcpy(dobash,"cd ~/LanGongFile/ && git clone ");
strcat(dobash,name);
strcat(dobash," && bash before.sh");
system(dobash);
printf("\n\n Install successfully! \n");
return 0;
}
else if(strcmp(clas,"zff")==0){
printf(" Install form OhZff-LanGong-GitHub : \n");
strcpy(temp,argv[3]);
strcpy(name,trim(temp));
char dobash[105];
strcpy(dobash,"cd ~/LanGongFile/ && git clone https://github.com/ohzff/");
strcat(dobash,name);
strcat(dobash,".git && cd ");
strcat(dobash,name);
strcat(dobash," && bash before.sh");
system(dobash);
printf("\n\n Install successfully! \n");
return 0;
}
cout<<"Not Found this : "<<clas<<endl;
return 1;
}
else if(strcmp(type,"ls")==0){
printf(" List: \n\n\n");
system("cd ~/LanGongFile/ && ls");
printf(" \n\n Load list successfully! \n");
return 0;
}
else if(strcmp(type,"run")==0){
char dobash[10005];
strcpy(dobash,"bash run.sh ");
strcat(dobash,argv[2]);
system(dobash);
system("echo -n 'Run Packages at ' >> ~/.config/LanFilePackage.log && date -u >> ~/.config/LanFilePackage.log");
return 0;
}
else if(strcmp(type,"help")==0){
system("bash help.sh");
return 0;
}
else if(strcmp(type,"update")==0){
system("git pull");
return 0;
}
else if(strcmp(type,"log")==0){
system("echo ' Log:'&&echo&&cat ~/.config/LanFilePackage.log");
return 0;
}
else if(strcmp(type,"version")==0){
system("bash version.sh");
return 0;
}
else if(strcmp(type,"search")==0){
system("echo 'We found these Packages:' && curl https://langong-dev.github.io/Package/repos");
system("echo -n 'Search Packages at ' >> ~/.config/LanFilePackage.log && date -u >> ~/.config/LanFilePackage.log");
return 0;
}
else if(strcmp(type,"uninstall")==0){
if(argv[2]==NULL){
char nameerr[]="Name";
throw nameerr;
}
strcpy(name,argv[2]);
char dobash[1000];
strcpy(dobash,"cd ~/LanGongFile/ && rm -rf ");
strcat(dobash,name);
system(dobash);
system("echo -n 'Uninstall Packages at ' >> ~/.config/LanFilePackage.log && date -u >> ~/.config/LanFilePackage.log");
return 0;
}
else if(strcmp(type,"init")==0){
if(argv[2]==NULL){
char nameerr[]="Name";
throw nameerr;
}
strcpy(name,argv[2]);
char dobash[1000];
strcpy(dobash,"mkdir ~/LanGongFile/");
strcat(dobash,name);
strcat(dobash," && cd ~/LanGongFile/");
strcat(dobash,name);
strcat(dobash," && echo 'fun(){' >> in.index && echo '#Run your APP' >> in.index && echo '}' >> in.index && echo '#We will run it after install' >> before.sh");
system(dobash);
printf("Please input 'How to run your app' into 'index.in' (in BashScript), and input 'Something after install into 'before.sh' (in BashScript).\n\nYou can publish your app in GitHub, and tell us at LanGongINC@yeah.net!\nWe will help you!\n");
return 0;
}
cout<<"Not Found this : "<<type<<endl<<endl<<"Do you need help?"<<endl<<"Input 'lfp help' .";
system("echo 'Error 1: Something not found.' >> ~/.config/LanFilePackage.log");
}
catch(char* ename){
printf(" Oh! You did not input the %s .\n\n Need help?\n Input this 'lfp help'.\n",ename);
system("echo 'Error 2: Something was not inputed.' >> ~/.config/LanFilePackage.log");
return 2;
}
return 1;
}