-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.cpp
More file actions
80 lines (58 loc) · 2.27 KB
/
commands.cpp
File metadata and controls
80 lines (58 loc) · 2.27 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
#include <iostream>
#include <string>
#include <cstdio>
#include <windows.h>
std::string getDirectoryPath(TCHAR *filePath, int steps){
int i = lstrlen(filePath);
std::string directoryPath;
for(int step = 0; step < steps; step++) {
for (; i >= 0; i--)
if (filePath[i] == '\\')
break;
i--;
}
i++;
for(int j = 0; j < i; j++){
directoryPath += filePath[j];
if(filePath[j] == '\\')
directoryPath += '\\';
}
return directoryPath;
}
void patchSpaces(std::string &str){
for(int i = 0; i < str.length(); i++)
if(str[i] == ' ')
str[i] = '_';
}
int main(){
TCHAR filePath[MAX_PATH];
GetModuleFileName(nullptr, filePath, MAX_PATH);
std::string valid[] = {"show", "mostrar", "deactivate", "desactivar", "reset_en", "reset_es"};
std::string executablePath = getDirectoryPath(filePath, 1) + "\\\\CReminders.exe";
std::string input;
printf("Enter one of the options:\n\n");
printf("show\n");
printf("Quickly gives a preview of all reminders\n\n");
printf("deactivate\n");
printf("Deactivates the program. To reactivate it you must run CReminders.exe again\n\n");
printf("reset en\n");
printf("Resets the info.txt file to its original state, in english. Note that this will delete all the reminders that you created\n\n\n");
printf("Introduzca una de las opciones:\n\n");
printf("mostrar\n");
printf("Muestra rapidamente como se verian los recordatorios\n\n");
printf("desactivar\n");
printf("Desactiva el programa. Para volver a activarlo se debe ejecutar CReminders.exe de nuevo\n\n");
printf("reset es\n");
printf("Resetea el archivo info.txt a su estado inicial, en espanol. Note que esto borrara todos los recordatorios que haya creado\n\n");
std::getline(std::cin, input);
patchSpaces(input);
while(!(input == "exit" || input == "salir")) {
if(std::none_of(std::begin(valid), std::end(valid), [input](std::string str){return input == str;}))
printf("Invalid input\n\n");
else
ShellExecuteA(nullptr, "open", executablePath.c_str(), input.c_str(), nullptr, SW_SHOW);
std::getline(std::cin, input);
patchSpaces(input);
}
return 0;
}