-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest.cpp
79 lines (59 loc) · 1.51 KB
/
test.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
#include "include/clt.h"
#include "include/utils.h"
extern char **environ;
void test_run() {
// init();
setenv("SHELL", "test", 1);
CliTools::envp e(environ);
string str2 = "\033[0;32m"+string(getenv("USER"))+"\033[0m";
string str1 = (getenv("PWD"));
string str3 = (getenv("LOGNAME"));
CliTools::prompt p = {str2, "@", "\033[0;31m"+string(getenv("PWD"))+"\033[0m", "$ "};
// cout << p.PS1 << endl;
// e.__list_path();
cout << welcome();
while(1) {
string line;
if((line = get_input(&p)) == "exit") {
break;
}
if(line == "") {
continue;
}
vector <string> commands;
CliTools::string_to_vect(commands, line.c_str(), " ");
cout << error_code_handle(CliTools::command_handler(commands, &e));
p.update({str2, "@", "\033[0;31m"+string(getenv("PWD"))+"\033[0m", "$ "});
}
cout << "SUCCESS!!!!" << endl;
}
void test_sandbox() {
for(auto it: locate(".", "Harry")) {
cout << it << endl;
}
// for(auto res: sgown("./tmp", "cat")) {
// cout << endl << res.first << endl;
// for(auto it: res.second) {
// cout << it.first << " " << it.second << endl;
// }
// }
// for(auto it: search_file("tmp/AesopTales.txt", "cat")) {
// cout << it.first << " " << it.second << endl;
// }
}
void run_tests(char** args, int no_of_args) {
int i = 0;
if(no_of_args > 0) {
string mode(args[0]);
if(mode == "-r") {
test_run();
}
if(mode == "-s") {
test_sandbox();
}
}
}
int main(int argl, char** argv) {
run_tests(argv + 1, argl - 1);
return 0;
}