summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-04-26 18:58:39 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-04-26 18:58:39 +0200
commitb7d6933be6a05acf507299dbde64a7c4e9850111 (patch)
tree2c59a3c2d5596bae58b12b2735b0745049191784
parent224073d3b2059ca5eea46d78235ab6476ecc1889 (diff)
downloadxK-b7d6933be6a05acf507299dbde64a7c4e9850111.tar.gz
xK-b7d6933be6a05acf507299dbde64a7c4e9850111.tar.xz
xK-b7d6933be6a05acf507299dbde64a7c4e9850111.zip
degesch: brevify /help with no arguments
-rw-r--r--degesch.c26
1 files 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;