-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.cpp
56 lines (43 loc) · 1.26 KB
/
entrypoint.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
54
55
56
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <iostream>
#include <string>
#include "parser.h"
#include "CLI/wrapper.h"
#include "Libraries/linenoise.h"
#include "CLI/interface.h"
#define HIST_FILENAME ".polyBobHistory"
int main(int argc, char **argv)
{
char* line;
unsigned int promptNb = 1;
char promptMsg[100];
srand(time(NULL));
printLogo();
/* Set the completion callback. This will be called every time the
* user uses the <tab> key. */
linenoiseSetCompletionCallback(completion);
/* Load history from file.*/
linenoiseHistoryLoad(HIST_FILENAME); /* Load the history at startup */
snprintf(promptMsg, 100, "%s[%d]: ", "\033[0m", promptNb);
while((line = linenoise(promptMsg)) != NULL)
{
linenoiseHistoryAdd(line); /* Add to the history. */
linenoiseHistorySave(HIST_FILENAME); /* Save the history on disk. */
/* Do something with the string. */
rmSuperscript(line);
if(line[0] == '/')
parseCommand(&(line[1]));
else if(!strcmp(line, "exit") || !strcmp(line, "quit") || (line[1] == 0 && (line[0] == 'e' || line[0] == 'q')))
break;
else if(line[0] != '\0')
{
simpleParserAPI(line);
}
snprintf(promptMsg, 100, "[%d]: ", ++promptNb);
}
finalProcessing();
return 0;
}