-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappmanager.cpp
More file actions
155 lines (94 loc) · 2.77 KB
/
Copy pathappmanager.cpp
File metadata and controls
155 lines (94 loc) · 2.77 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
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
#include "src/Header/Log.hpp"
#include "src/Header/App.hpp"
#include <iostream>
#include <string>
enum class ARGV {
HOME,
ADD,
DELETE,
RUN,
RESET,
LIST,
LOG,
VERSION,
HELP,
INVALID,
REMOVE
};
ARGV string_to_argv(const std::string& argv_text) {
if (argv_text == "home") return ARGV::HOME;
if (argv_text == "add") return ARGV::ADD;
if (argv_text == "run") return ARGV::RUN;
if (argv_text == "delete") return ARGV::DELETE;
if (argv_text == "reset") return ARGV::RESET;
if (argv_text == "list") return ARGV::LIST;
if (argv_text == "log") return ARGV::LOG;
if (argv_text == "version" || argv_text == "-v") return ARGV::VERSION;
if (argv_text == "help" || argv_text == "-h") return ARGV::HELP;
if (argv_text == "remove" || argv_text == "-r") return ARGV::REMOVE;
return ARGV::INVALID;
}
int main(const int argc, const char* argv[]) {
//================================
// Initialize variable
//================================
Log logeer;
App app;
auto cmd = ARGV::HOME;
const std::string APP_VERSION = "1.0.6";
if (argc > 1) cmd = string_to_argv(argv[1]);
switch (cmd) {
case ARGV::HOME:
app.home();
break;
case ARGV::ADD:
app.add_command();
break;
case ARGV::RUN:
if (argc == 3) {
app.run_command(argv[2]);
}else {
std::cout << "Invalid Command" << std::endl;
std::cout << "Use : appmanager help" << std::endl;
}
break;
case ARGV::DELETE:
if (argc == 3) {
app.delete_command(argv[2]);
}else {
std::cout << "Invalid Command" << std::endl;
std::cout << "Use : appmanager help" << std::endl;
}
break;
case ARGV::RESET:
app.reset_command();
break;
case ARGV::LIST:
app.list();
break;
case ARGV::LOG:
if (argc == 3) {
app.log_clear(argv[2]);
}else {
std::cout << "Invalid Command" << std::endl;
std::cout << "Use : appmanager help" << std::endl;
}
break;
case ARGV::VERSION:
app.version(APP_VERSION);
break;
case ARGV::HELP:
app.help();
break;
case ARGV::INVALID:
std::cout << "Invalid Command" << std::endl;
std::cout << "Use : appmanager help" << std::endl;
break;
case ARGV::REMOVE:
app.remove_application();
break;
default:
break;
}
return 0;
}