-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
39 lines (38 loc) · 825 Bytes
/
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
#include "src/eval.h"
#include "src/Engine.h"
#include "src/listener.h"
#include "src/shortkeys.h"
#include <iostream>
#include <sys/types.h>
#include <unistd.h>
std::string to_string(char* s){
std::string res;
while(*s){
res += *s;
s++;
}
return res;
}
int main(int argc, char* argv[])
{
try{
Engine e;
if(argc >= 2){ // adds a key
std::string command = to_string(argv[1]);
if(command == "--add"){
e.add_key(to_string(argv[2]), to_string(argv[3]));
}else if(command == "--remove"){
e.remove_key(to_string(argv[2]));
}else if(command == "--list"){
e.list_keys();
}else if(command == "--help"){
e.show_help();
}
}else{
e.run();
}
}catch(const char* error_message){
std::cerr << error_message;
}
return 0;
}