levy5307 commented on code in PR #914:
URL: https://github.com/apache/incubator-pegasus/pull/914#discussion_r889948639


##########
src/shell/command_utils.cpp:
##########
@@ -45,3 +45,35 @@ bool validate_ip(shell_context *sc,
     err_info = fmt::format("invalid ip:port={}, can't find it in the cluster", 
ip_str);
     return false;
 }
+
+bool confirm_unsafe_command(const std::string &action)
+{
+    const int max_attempts = 5;
+    int attempts = 0;
+    for (; attempts < max_attempts; ++attempts) {
+        fmt::print(stdout,
+                   "PLEASE be CAUTIOUS with this operation ! "
+                   "Are you sure to {} ? [Y/n]: ",
+                   action);
+
+        int choice = fgetc(stdin);
+        int len = 0;
+        for (int c = choice; c != '\n' && c != EOF; ++len) {
+            c = fgetc(stdin);
+        }
+        if (len != 1) {
+            continue;
+        }
+
+        if (choice == 'Y') {

Review Comment:
   ```if (choice == 'Y' || choice == 'y')```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to