degesch: improve /help display

This commit is contained in:
Přemysl Eric Janouch 2015-05-09 23:08:30 +02:00
parent 789db85915
commit 5b9e263ca7
1 changed files with 9 additions and 2 deletions

View File

@ -4944,11 +4944,18 @@ 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:");
int longest = 0;
for (size_t i = 0; i < N_ELEMENTS (g_command_handlers); i++)
{
int len = strlen (g_command_handlers[i].name);
longest = MAX (longest, len);
}
for (size_t i = 0; i < N_ELEMENTS (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);
buffer_send_status (ctx, ctx->global_buffer, " %-*s %s",
longest, handler->name, handler->description);
}
return true;
}