[client] fix option output counts and dynamic name padding

This commit is contained in:
Geoffrey McRae 2017-12-19 10:56:23 +11:00
parent c38e38d43d
commit f4b95eeda9

View File

@ -1096,13 +1096,31 @@ int main(int argc, char * argv[])
{ {
if (strcasecmp(optarg, "list") == 0) 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"); fprintf(stderr, "\nRenderer Option List\n");
for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i) for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i)
{ {
const LG_Renderer * r = LG_Renderers[i]; const LG_Renderer * r = LG_Renderers[i];
fprintf(stderr, "\n%s\n", r->get_name()); fprintf(stderr, "\n%s\n", r->get_name());
for(unsigned int i = 0; i < r->option_count; ++i) for(unsigned int j = 0; j < r->option_count; ++j)
fprintf(stderr, " %10s - %s\n", r->options[i].name, r->options[i].desc); {
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"); fprintf(stderr, "\n");
return -1; return -1;