소스 검색

deleteme now prints a success message (+ autoformat)

Denys 5 년 전
부모
커밋
0d4f8d5dac
4개의 변경된 파일18개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 1
      cli/include/cmdman.h
  2. 1 0
      cli/include/userioman.h
  3. 5 5
      cli/src/cmdman.cpp
  4. 10 0
      cli/src/userioman.cpp

+ 2 - 1
cli/include/cmdman.h

@@ -120,7 +120,8 @@ private:
   CmdRet cmdLogin(vector<string> args);
   const string descSignup = "sign up and login to the server";
   CmdRet cmdSignup(vector<string> args);
-  const string descDeleteme = "delete the user you are currently logged in as (needs to be confirmed with the password)";
+  const string descDeleteme = "delete the user you are currently logged in as "
+                              "(needs to be confirmed with the password)";
   CmdRet cmdDeleteme(vector<string> args);
 
   /**

+ 1 - 0
cli/include/userioman.h

@@ -47,6 +47,7 @@ private:
   void printPutdata(Json::Value root);
   void printGetdata(Json::Value root);
   void printListdata(Json::Value root);
+  void printDeleteme(Json::Value root);
 
   /**
    * Mutex for synchronized message output

+ 5 - 5
cli/src/cmdman.cpp

@@ -260,14 +260,14 @@ CmdMan::CmdRet CmdMan::cmdDeleteme(vector<string> args) {
   CmdRet retval;
   DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
   Json::Value root;
-  
+
   root["command"] = "deleteme";
-  
-  if(args.size() < 1) {
+
+  if (args.size() < 1) {
     retval.type = error;
     root["accept"] = false;
     root["error"] = "not enough arguments, at least 1 argument required";
-  } else {  
+  } else {
     retval.type = send;
     root["pass"] = args[0];
   }
@@ -680,7 +680,7 @@ CmdMan::CmdRet CmdMan::handleDeleteme(Json::Value root) {
   if (!root["accept"].asBool()) {
     retval.type = error;
   } else {
-    retval.type = close;
+    retval.type = close | print;
   }
   retval.msg = root;
   return retval;

+ 10 - 0
cli/src/userioman.cpp

@@ -31,6 +31,7 @@ UserIoMan::UserIoMan(char *ipcstring) : IoMan(ipcstring) {
   printmap["signup"] = &UserIoMan::printSignup;
   printmap["putdata"] = &UserIoMan::printPutdata;
   printmap["getdata"] = &UserIoMan::printGetdata;
+  printmap["deleteme"] = &UserIoMan::printDeleteme;
 }
 
 UserIoMan::~UserIoMan() { delete reader; }
@@ -175,6 +176,15 @@ void UserIoMan::printSignup(Json::Value root) {
     std::cout << "Signup ok. You are now logged in." << std::endl;
 }
 
+void UserIoMan::printDeleteme(Json::Value root) {
+  if (!root["accept"].asBool()) {
+    std::cout << "User deletion failed: " << root["error"].asString()
+              << std::endl;
+  } else
+    std::cout << "User deletion ok. You are now disconnected from the server."
+              << std::endl;
+}
+
 void UserIoMan::printPutdata(Json::Value root) {}
 
 void UserIoMan::printGetdata(Json::Value root) {}