useriomanager.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <useriomanager.hpp>
  2. #include <iostream>
  3. #include <jsoncpp/json/json.h>
  4. #include <readline/readline.h>
  5. void UserIoManager::run() {
  6. std::cout << "UserIoManager::run() says hello!" << std::endl;
  7. bool keep_reading = true;
  8. while(keep_reading){
  9. // read an input line
  10. char *line = readline ("ccats> ");
  11. // if no input, do not add to history, and go to reading next line
  12. if (strlen(line) == 0) {
  13. free(line);
  14. continue;
  15. }
  16. // add the line to history
  17. add_history(line);
  18. if(!strcmp(line, "help")) {
  19. std::printf("ccats command line interface\n");
  20. std::printf("available COMMANDs are:\n");
  21. std::printf("help - shows this help\n");
  22. std::printf("status - asks the server for status\n");
  23. std::printf("close - closes the connection to the server\n");
  24. }
  25. else if (!strcmp(line, "status")) {
  26. // do stuff
  27. }
  28. else if (!strcmp(line, "close")) {
  29. // do stuff
  30. keep_reading = false;
  31. }
  32. free(line);
  33. }
  34. return;
  35. }