aboutsummaryrefslogtreecommitdiff
path: root/client/acronc/client.c
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2022-07-26 23:11:28 -0700
committerTrumeet <yuuta@yuuta.moe>2022-07-26 23:11:28 -0700
commit8037d8a6000423a3ae59657cded4465fdd6fc74a (patch)
tree5e56ce6cfe953a1143482b439e9ee552541685b1 /client/acronc/client.c
parentc6948fd983fa1855b2dadba50aa50f576f54bdda (diff)
downloadacron-8037d8a6000423a3ae59657cded4465fdd6fc74a.tar
acron-8037d8a6000423a3ae59657cded4465fdd6fc74a.tar.gz
acron-8037d8a6000423a3ae59657cded4465fdd6fc74a.tar.bz2
acron-8037d8a6000423a3ae59657cded4465fdd6fc74a.zip
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 <yuuta@yuuta.moe>
Diffstat (limited to 'client/acronc/client.c')
-rw-r--r--client/acronc/client.c9
1 files changed, 9 insertions, 0 deletions
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: {