From 8037d8a6000423a3ae59657cded4465fdd6fc74a Mon Sep 17 00:00:00 2001 From: Trumeet Date: Tue, 26 Jul 2022 23:11:28 -0700 Subject: feat(acronc): prettify cli experience 1. Make SIGINT interrupt the current operation by forcing stdin to listen again (because the spec currently does not specify how to send the final response, so acronc will wait forever in case of invalid commands) 2. Prettify prompt and output. Signed-off-by: Trumeet --- client/acronc/client.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'client/acronc/client.c') diff --git a/client/acronc/client.c b/client/acronc/client.c index 5553d4c..3e8ca76 100644 --- a/client/acronc/client.c +++ b/client/acronc/client.c @@ -71,8 +71,10 @@ static void handle_response(const ac_response_t *response) { switch (response->type) { case AC_RESPONSE_OK: { ac_response_ok_t *o = (ac_response_ok_t *) response; +#ifdef DEBUG printf("Request %d OK.\n", o->id); +#endif break; } case AC_RESPONSE_ERROR: { @@ -85,18 +87,25 @@ static void handle_response(const ac_response_t *response) { } case AC_RESPONSE_CMD_OUT: { ac_response_cmd_out_t *o = (ac_response_cmd_out_t *) response; +#ifdef DEBUG printf("Request %d output by %s: %s.\n", o->id, o->sender, o->out); +#else + printf("%s\n", + o->out); +#endif break; } case AC_RESPONSE_CMD_RESULT: { ac_response_cmd_result_t *o = (ac_response_cmd_result_t *) response; +#ifdef DEBUG printf("Request %d is done: %s (%d).\n", o->id, o->success ? "Success" : "Failed", o->result); +#endif DEBUG break; } default: { -- cgit v1.2.3