From 5b9e263ca7de0de470ebd1f0ccb7c8b05da788d7 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sat, 9 May 2015 23:08:30 +0200 Subject: degesch: improve /help display --- degesch.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/degesch.c b/degesch.c index 01cc65f..37c0c1d 100644 --- a/degesch.c +++ b/degesch.c @@ -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; } -- cgit v1.2.3-70-g09d2