From b7d6933be6a05acf507299dbde64a7c4e9850111 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sun, 26 Apr 2015 18:58:39 +0200 Subject: degesch: brevify /help with no arguments --- degesch.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/degesch.c b/degesch.c index caec35b..972eb3e 100644 --- a/degesch.c +++ b/degesch.c @@ -3245,16 +3245,6 @@ g_command_handlers[] = "command" }, }; -static void -show_command_help (struct app_context *ctx, - const char *quote, struct command_handler *handler) -{ - buffer_send_status (ctx, ctx->global_buffer, "%s%s: %s", - quote, handler->name, handler->description); - buffer_send_status (ctx, ctx->global_buffer, "%s Arguments: %s", - quote, handler->usage); -} - static bool handle_command_help (struct app_context *ctx, char *arguments) { @@ -3263,18 +3253,28 @@ handle_command_help (struct app_context *ctx, char *arguments) buffer_send_status (ctx, ctx->global_buffer, "%s", ""); buffer_send_status (ctx, ctx->global_buffer, "Commands:"); for (size_t i = 0; i < N_ELEMENTS (g_command_handlers); i++) - show_command_help (ctx, " ", &g_command_handlers[i]); + { + struct command_handler *handler = &g_command_handlers[i]; + buffer_send_status (ctx, ctx->global_buffer, " %s: %s", + handler->name, handler->description); + } return true; } char *command = cut_word (&arguments); for (size_t i = 0; i < N_ELEMENTS (g_command_handlers); i++) - if (!strcasecmp_ascii (command, g_command_handlers[i].name)) + { + struct command_handler *handler = &g_command_handlers[i]; + if (!strcasecmp_ascii (command, handler->name)) { buffer_send_status (ctx, ctx->global_buffer, "%s", ""); - show_command_help (ctx, "", &g_command_handlers[i]); + buffer_send_status (ctx, ctx->global_buffer, "%s: %s", + handler->name, handler->description); + buffer_send_status (ctx, ctx->global_buffer, " Arguments: %s", + handler->usage); return true; } + } buffer_send_error (ctx, ctx->global_buffer, "%s: %s", "No such command", command); return true; -- cgit v1.2.3-70-g09d2