mirror of
https://github.com/curl/curl.git
synced 2026-07-31 21:08:04 +03:00
print_category: print help descriptions aligned
Adjust the description position to make an aligned column when doing help listings, which is more pleasing to the eye. Suggested-by: Gisle Vanem Closes #7792
This commit is contained in:
parent
85f91248cf
commit
24ffdc8826
4 changed files with 36 additions and 19 deletions
|
|
@ -115,9 +115,26 @@ static const struct feat feats[] = {
|
|||
static void print_category(curlhelp_t category)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t longopt = 5;
|
||||
size_t longdesc = 5;
|
||||
|
||||
for(i = 0; helptext[i].opt; ++i) {
|
||||
size_t len;
|
||||
if(!(helptext[i].categories & category))
|
||||
continue;
|
||||
len = strlen(helptext[i].opt);
|
||||
if(len > longopt)
|
||||
longopt = len;
|
||||
len = strlen(helptext[i].desc);
|
||||
if(len > longdesc)
|
||||
longdesc = len;
|
||||
}
|
||||
if(longopt + longdesc > 80)
|
||||
longopt = 80 - longdesc;
|
||||
|
||||
for(i = 0; helptext[i].opt; ++i)
|
||||
if(helptext[i].categories & category) {
|
||||
printf(" %-18s %s\n", helptext[i].opt, helptext[i].desc);
|
||||
printf(" %-*s %s\n", longopt, helptext[i].opt, helptext[i].desc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue