-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli-action.cpp
53 lines (42 loc) · 1.01 KB
/
cli-action.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
#include <iostream>
#include <vector>
#include <functional>
#include "cli-action.h"
#include "cli-action-param.h"
using namespace std;
CLIAction::CLIAction(vector<string> names, string description, std::function<void ()> function) {
for(int i = 0; i < names.size(); i++) {
this->names.push_back(names[i]);
}
this->description = description;
this->function = function;
this->isNoAction = false;
}
CLIAction::CLIAction() {}
CLIAction::~CLIAction() {}
vector<string> CLIAction::getNames() {
return names;
}
string CLIAction::getName(int i) {
return names[i];
}
string CLIAction::namesToString() {
string output = names[0];
for(int i = 1; i < names.size(); i++) {
output += ", " + names[i];
}
return output;
}
string CLIAction::getDescription() {
return description;
}
void CLIAction::setCalledAction(string calledAction) {
this->calledAction = calledAction;
}
string CLIAction::getCalledAction() {
return calledAction;
}
void CLIAction::execute() {
// Execute lambda function for this action
function();
}