|
@@ -3,6 +3,55 @@
|
|
|
#include <iostream>
|
|
|
#include <jsoncpp/json/json.h>
|
|
|
|
|
|
+#include <readline/readline.h>
|
|
|
+
|
|
|
+
|
|
|
void UserIoManager::run() {
|
|
|
std::cout << "UserIoManager::run() says hello!" << std::endl;
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ bool keep_reading = true;
|
|
|
+ while(keep_reading){
|
|
|
+
|
|
|
+ // read an input line
|
|
|
+ char *line = readline ("ccats> ");
|
|
|
+
|
|
|
+ // if no input, do not add to history, and go to reading next line
|
|
|
+ if (strlen(line) == 0) {
|
|
|
+ free(line);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // add the line to history
|
|
|
+ add_history(line);
|
|
|
+
|
|
|
+ if(!strcmp(line, "help")) {
|
|
|
+
|
|
|
+ std::printf("ccats command line interface\n");
|
|
|
+ std::printf("available COMMANDs are:\n");
|
|
|
+ std::printf("help - shows this help\n");
|
|
|
+ std::printf("status - asks the server for status\n");
|
|
|
+ std::printf("close - closes the connection to the server\n");
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (!strcmp(line, "status")) {
|
|
|
+
|
|
|
+ // do stuff
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (!strcmp(line, "close")) {
|
|
|
+
|
|
|
+ // do stuff
|
|
|
+
|
|
|
+ keep_reading = false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ free(line);
|
|
|
+ }
|
|
|
+
|
|
|
+ return;
|
|
|
+}
|