degesch: brevify /help with no arguments
This commit is contained in:
parent
224073d3b2
commit
b7d6933be6
26
degesch.c
26
degesch.c
|
@ -3245,16 +3245,6 @@ g_command_handlers[] =
|
||||||
"command" },
|
"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
|
static bool
|
||||||
handle_command_help (struct app_context *ctx, char *arguments)
|
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, "%s", "");
|
||||||
buffer_send_status (ctx, ctx->global_buffer, "Commands:");
|
buffer_send_status (ctx, ctx->global_buffer, "Commands:");
|
||||||
for (size_t i = 0; i < N_ELEMENTS (g_command_handlers); i++)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *command = cut_word (&arguments);
|
char *command = cut_word (&arguments);
|
||||||
for (size_t i = 0; i < N_ELEMENTS (g_command_handlers); i++)
|
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", "");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
buffer_send_error (ctx, ctx->global_buffer,
|
buffer_send_error (ctx, ctx->global_buffer,
|
||||||
"%s: %s", "No such command", command);
|
"%s: %s", "No such command", command);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue