diff --git a/sources/console.c b/sources/console.c index 35c0df6ab..edfc7a9ff 100644 --- a/sources/console.c +++ b/sources/console.c @@ -18,6 +18,7 @@ typedef enum { OD_LSERVER_PREP_STMTS, OD_LCLIENTS, OD_LLISTS, + OD_LHELP, OD_LSET, OD_LCREATE, OD_LDROP, @@ -37,6 +38,7 @@ typedef enum { static od_keyword_t od_console_keywords[] = { od_keyword("kill_client", OD_LKILL_CLIENT), od_keyword("reload", OD_LRELOAD), + od_keyword("help", OD_LHELP), od_keyword("show", OD_LSHOW), od_keyword("stats", OD_LSTATS), od_keyword("servers", OD_LSERVERS), @@ -274,6 +276,34 @@ static int od_console_show_err_router_stats_cb(od_error_logger_t *l, return od_console_show_router_stats_err_add(stream, l); } +static inline int od_console_show_help(od_client_t *client, + machine_msg_t *stream) +{ + assert(stream); + + char msg[OD_QRY_MAX_SZ]; + int msg_len; + va_list args; + + char *message = + "\n" + "Console usage\n" + "\tSHOW STATS|HELP|POOLS|POOLS_EXTENDED|DATABASES|SERVER_PREP_STMTS|SERVERS|CLIENTS\n" + "\tSHOW LISTS|ERRORS|ERRORS_PER_ROUTE|VERSION|LISTEN|STORAGES\n" + "\tKILL_CLIENT \n" + "\tRELOAD\n" + "\tSET key=arg\n" + "\tCREATE \n" + "\tDROP SERVERS|MODULE |"; + stream = kiwi_be_write_notice_console_usage(stream, message); + + int rc = kiwi_be_write_complete(stream, "SHOW", 5); + if (rc == NOT_OK_RESPONSE) { + return rc; + } + return rc; +} + static inline int od_console_show_stats(od_client_t *client, machine_msg_t *stream) { @@ -1719,6 +1749,8 @@ static inline int od_console_show(od_client_t *client, machine_msg_t *stream, switch (keyword->id) { case OD_LSTATS: return od_console_show_stats(client, stream); + case OD_LHELP: + return od_console_show_help(client, stream); case OD_LPOOLS: return od_console_show_pools(client, stream, false); case OD_LPOOLS_EXTENDED: diff --git a/third_party/kiwi/kiwi/be_write.h b/third_party/kiwi/kiwi/be_write.h index 32d2cee47..05a08db4e 100644 --- a/third_party/kiwi/kiwi/be_write.h +++ b/third_party/kiwi/kiwi/be_write.h @@ -117,6 +117,14 @@ kiwi_be_write_notice_as(machine_msg_t *msg, char *severity, int severity_len, return msg; } +KIWI_API static inline machine_msg_t * +kiwi_be_write_notice_console_usage(machine_msg_t *msg, char *detail) +{ + return kiwi_be_write_notice_as(msg, "NOTICE", 7, + KIWI_SUCCESSFUL_COMPLETION, NULL, 0, + NULL, 0, detail, strlen(detail)); +} + KIWI_API static inline machine_msg_t * kiwi_be_write_notice_info(machine_msg_t *msg, char *message, int len) {