From f4b95eeda9210823dbcfce5c5760ff6f151f52c9 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 19 Dec 2017 10:56:23 +1100 Subject: [PATCH] [client] fix option output counts and dynamic name padding --- client/main.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/client/main.c b/client/main.c index 28c78849..3efbb22c 100644 --- a/client/main.c +++ b/client/main.c @@ -1096,13 +1096,31 @@ int main(int argc, char * argv[]) { if (strcasecmp(optarg, "list") == 0) { + size_t maxLen = 0; + for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i) + { + const LG_Renderer * r = LG_Renderers[i]; + for(unsigned int j = 0; j < r->option_count; ++j) + { + const size_t len = strlen(r->options[j].name); + if (len > maxLen) + maxLen = len; + } + } + fprintf(stderr, "\nRenderer Option List\n"); for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i) { const LG_Renderer * r = LG_Renderers[i]; fprintf(stderr, "\n%s\n", r->get_name()); - for(unsigned int i = 0; i < r->option_count; ++i) - fprintf(stderr, " %10s - %s\n", r->options[i].name, r->options[i].desc); + for(unsigned int j = 0; j < r->option_count; ++j) + { + const size_t pad = maxLen - strlen(r->options[j].name); + for(int i = 0; i < pad; ++i) + fputc(' ', stderr); + + fprintf(stderr, " %s - %s\n", r->options[j].name, r->options[j].desc); + } } fprintf(stderr, "\n"); return -1;