empiredan commented on code in PR #2229: URL: https://github.com/apache/incubator-pegasus/pull/2229#discussion_r2048309477
########## src/shell/commands/table_management.cpp: ########## @@ -1068,3 +1068,100 @@ bool set_max_replica_count(command_executor *e, shell_context *sc, arguments arg return true; } + +bool get_atomic_idempotent(command_executor *e, shell_context *sc, arguments args) +{ + // get_atomic_idempotent <app_name> [-j|--json] + + // All valid flags are given as follows. + static const std::set<std::string> flags = {"j", "json"}; + + argh::parser cmd(args.argc, args.argv, argh::parser::PREFER_PARAM_FOR_UNREG_OPTION); + + // Check if the input flags are valid, and there is exact one positional argument + // (i.e. app_name). + const auto &check = validate_cmd(cmd, {}, flags, 1); + if (!check) { + SHELL_PRINTLN_ERROR("{}", check.description()); + return false; + } + + // Get the only positional argument as app_name. + const std::string app_name(cmd(1).str()); + + const bool json = cmd[{"-j", "--json"}]; + + const auto &result = sc->ddl_client->get_atomic_idempotent(app_name); + auto status = result.get_error(); + if (status) { + status = FMT_ERR(result.get_value().err, result.get_value().hint_message); + } + + if (!status) { + SHELL_PRINTLN_ERROR("get_atomic_idempotent failed, error={}", status); + return true; Review Comment: Clever ! The return value of shell commands follows the convention that only syntax or usage errors (e.g., invalid arguments) cause a return value of false. Even if an error occurs on the server side during processing, the command will return true. This can be somewhat misleading at first glance. -- 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: dev-unsubscr...@pegasus.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pegasus.apache.org For additional commands, e-mail: dev-h...@pegasus.apache.org