-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLI.cpp
More file actions
53 lines (46 loc) · 1.34 KB
/
CLI.cpp
File metadata and controls
53 lines (46 loc) · 1.34 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
/*
* CLI.cpp
*
* Author: 313361560 Shahar Rapp, 205866163 Ze'ev Binnes.
*/
#include "CLI.h"
CLI::CLI(DefaultIO* dio){
this->dio = dio;
this->dd = new DetectorData();
this->commands.push_back(new UploadCommand(dio, dd));
this->commands.push_back(new AlgSettingsCommand(dio, dd));
this->commands.push_back(new DetectCommand(dio, dd));
this->commands.push_back(new DisplayResultsCommand(dio, dd));
this->commands.push_back(new UploadAndAnalyzeCommand(dio, dd));
this->commands.push_back(new ExitCommand(dio, dd));
}
void CLI::start(){
while (true) {
CLI::printMenu();
std:string strOption;
strOption = dio->read();
int option;
try {
option = std::stoi(strOption);
} catch(const std::exception& e) {
std::cerr << e.what() << '\n';
}
if (option == 6) {
break;
}
if (option > 0 && option < 6)
commands[option - 1]->execute();
}
}
void CLI::printMenu() {
std::string menuStartText =
"Welcome to the Anomaly Detection Server.\nPlease choose an option:\n";
this->dio->write(menuStartText);
for (auto c : commands) {
c->print_description();
}
}
CLI::~CLI() {
this->commands.clear();
delete dd;
}