mirror of
https://github.com/curl/curl.git
synced 2026-06-08 16:44:16 +03:00
cmdline-opts: shorter help texts
In an effort to increase the readability of the "--help all" output on narrow (80 column) terminals. Co-authored-by: Jay Satiro Closes #13169
This commit is contained in:
parent
647e86a3ef
commit
fe9f68fa61
70 changed files with 215 additions and 170 deletions
|
|
@ -73,6 +73,11 @@ static const struct category_descriptors categories[] = {
|
|||
{NULL, NULL, CURLHELP_HIDDEN}
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#define BORDER 78
|
||||
#else
|
||||
#define BORDER 79
|
||||
#endif
|
||||
|
||||
static void print_category(curlhelp_t category)
|
||||
{
|
||||
|
|
@ -91,12 +96,21 @@ static void print_category(curlhelp_t category)
|
|||
if(len > longdesc)
|
||||
longdesc = len;
|
||||
}
|
||||
if(longopt + longdesc > 80)
|
||||
longopt = 80 - longdesc;
|
||||
|
||||
if(longopt + longdesc >= BORDER) {
|
||||
longdesc -= 3;
|
||||
longopt = BORDER -1 - longdesc;
|
||||
}
|
||||
for(i = 0; helptext[i].opt; ++i)
|
||||
if(helptext[i].categories & category) {
|
||||
printf(" %-*s %s\n", (int)longopt, helptext[i].opt, helptext[i].desc);
|
||||
int opt = (int)longopt;
|
||||
size_t desclen = strlen(helptext[i].desc);
|
||||
if(opt + desclen >= (BORDER -1)) {
|
||||
if(desclen < (BORDER -1))
|
||||
opt = (BORDER -2) - (int)desclen;
|
||||
else
|
||||
opt = 0;
|
||||
}
|
||||
printf(" %-*s %s\n", opt, helptext[i].opt, helptext[i].desc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue