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:
Daniel Stenberg 2024-03-25 10:02:30 +01:00
parent 647e86a3ef
commit fe9f68fa61
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
70 changed files with 215 additions and 170 deletions

View file

@ -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);
}
}

View file

@ -45,14 +45,14 @@ const struct helptxt helptext[] = {
{"-a, --append",
"Append to target file when uploading",
CURLHELP_FTP | CURLHELP_SFTP},
{" --aws-sigv4 <provider1[:provider2[:region[:service]]]>",
"Use AWS V4 signature authentication",
{" --aws-sigv4 <provider1[:prvdr2[:reg[:srv]]]>",
"AWS V4 signature auth",
CURLHELP_AUTH | CURLHELP_HTTP},
{" --basic",
"Use HTTP Basic Authentication",
"HTTP Basic Authentication",
CURLHELP_AUTH},
{" --ca-native",
"Use CA certificates from the native OS",
"Load CA certs from the OS",
CURLHELP_TLS},
{" --cacert <file>",
"CA certificate to verify peer against",
@ -64,7 +64,7 @@ const struct helptxt helptext[] = {
"Client certificate file and password",
CURLHELP_TLS},
{" --cert-status",
"Verify the status of the server cert via OCSP-staple",
"Verify server cert status OCSP-staple",
CURLHELP_TLS},
{" --cert-type <type>",
"Certificate type (DER/PEM/ENG/P12)",
@ -81,8 +81,8 @@ const struct helptxt helptext[] = {
{"-K, --config <file>",
"Read config from a file",
CURLHELP_CURL},
{" --connect-timeout <fractional seconds>",
"Maximum time allowed for connection",
{" --connect-timeout <seconds>",
"Maximum time allowed to connect",
CURLHELP_CONNECTION},
{" --connect-to <HOST1:PORT1:HOST2:PORT2>",
"Connect to host",
@ -91,10 +91,10 @@ const struct helptxt helptext[] = {
"Resumed transfer offset",
CURLHELP_CONNECTION},
{"-b, --cookie <data|filename>",
"Send cookies from string/file",
"Send cookies from string/load from file",
CURLHELP_HTTP},
{"-c, --cookie-jar <filename>",
"Write cookies to <filename> after operation",
"Save cookies to <filename> after operation",
CURLHELP_HTTP},
{" --create-dirs",
"Create necessary local directory hierarchy",
@ -106,10 +106,10 @@ const struct helptxt helptext[] = {
"Convert LF to CRLF in upload",
CURLHELP_FTP | CURLHELP_SMTP},
{" --crlfile <file>",
"Use this CRL list",
"Certificate Revocation list",
CURLHELP_TLS},
{" --curves <algorithm list>",
"(EC) TLS key exchange algorithm(s) to request",
{" --curves <list>",
"(EC) TLS key exchange algorithms to request",
CURLHELP_TLS},
{"-d, --data <data>",
"HTTP POST data",
@ -130,7 +130,7 @@ const struct helptxt helptext[] = {
"GSS-API delegation permission",
CURLHELP_AUTH},
{" --digest",
"Use HTTP Digest Authentication",
"HTTP Digest Authentication",
CURLHELP_PROXY | CURLHELP_AUTH | CURLHELP_HTTP},
{"-q, --disable",
"Disable .curlrc",
@ -157,7 +157,7 @@ const struct helptxt helptext[] = {
"DNS server addrs to use",
CURLHELP_DNS},
{" --doh-cert-status",
"Verify the status of the DoH server cert via OCSP-staple",
"Verify DoH server cert status OCSP-staple",
CURLHELP_DNS | CURLHELP_TLS},
{" --doh-insecure",
"Allow insecure DoH server connections",
@ -175,10 +175,10 @@ const struct helptxt helptext[] = {
"Crypto engine to use",
CURLHELP_TLS},
{" --etag-compare <file>",
"Pass an ETag from a file as a custom header",
"Load ETag from file",
CURLHELP_HTTP},
{" --etag-save <file>",
"Parse ETag from a request and save it to a file",
"Parse incoming ETag and save to a file",
CURLHELP_HTTP},
{" --expect100-timeout <seconds>",
"How long to wait for 100-continue",
@ -187,7 +187,7 @@ const struct helptxt helptext[] = {
"Fail fast with no output on HTTP errors",
CURLHELP_IMPORTANT | CURLHELP_HTTP},
{" --fail-early",
"Fail on first transfer error, do not continue",
"Fail on first transfer error",
CURLHELP_CURL},
{" --fail-with-body",
"Fail on HTTP errors but save the body",
@ -199,7 +199,7 @@ const struct helptxt helptext[] = {
"Specify multipart MIME data",
CURLHELP_HTTP | CURLHELP_UPLOAD},
{" --form-escape",
"Escape multipart form field/filenames using backslash",
"Escape form fields using backslash",
CURLHELP_HTTP | CURLHELP_UPLOAD},
{" --form-string <name=string>",
"Specify multipart MIME data",
@ -217,10 +217,10 @@ const struct helptxt helptext[] = {
"Control CWD usage",
CURLHELP_FTP},
{" --ftp-pasv",
"Use PASV/EPSV instead of PORT",
"Send PASV/EPSV instead of PORT",
CURLHELP_FTP},
{"-P, --ftp-port <address>",
"Use PORT instead of PASV",
"Send PORT instead of PASV",
CURLHELP_FTP},
{" --ftp-pret",
"Send PRET before PASV",
@ -235,19 +235,19 @@ const struct helptxt helptext[] = {
"Set CCC mode",
CURLHELP_FTP | CURLHELP_TLS},
{" --ftp-ssl-control",
"Require SSL/TLS for FTP login, clear for transfer",
"Require TLS for login, clear for transfer",
CURLHELP_FTP | CURLHELP_TLS},
{"-G, --get",
"Put the post data in the URL and use GET",
CURLHELP_HTTP | CURLHELP_UPLOAD},
{"-g, --globoff",
"Disable URL sequences and ranges using {} and []",
"Disable URL globbing with {} and []",
CURLHELP_CURL},
{" --happy-eyeballs-timeout-ms <milliseconds>",
"Time for IPv6 before trying IPv4",
{" --happy-eyeballs-timeout-ms <ms>",
"Time for IPv6 before IPv4",
CURLHELP_CONNECTION},
{" --haproxy-clientip <IP address>",
"Sets client IP in HAProxy PROXY protocol v1 header",
{" --haproxy-clientip <ip>",
"Set address in HAProxy PROXY",
CURLHELP_HTTP | CURLHELP_PROXY},
{" --haproxy-protocol",
"Send HAProxy PROXY protocol v1 header",
@ -262,10 +262,10 @@ const struct helptxt helptext[] = {
"Get help for commands",
CURLHELP_IMPORTANT | CURLHELP_CURL},
{" --hostpubmd5 <md5>",
"Acceptable MD5 hash of the host public key",
"Acceptable MD5 hash of host public key",
CURLHELP_SFTP | CURLHELP_SCP},
{" --hostpubsha256 <sha256>",
"Acceptable SHA256 hash of the host public key",
"Acceptable SHA256 hash of host public key",
CURLHELP_SFTP | CURLHELP_SCP},
{" --hsts <filename>",
"Enable HSTS with this cache file",
@ -295,7 +295,7 @@ const struct helptxt helptext[] = {
"Ignore the size of the remote resource",
CURLHELP_HTTP | CURLHELP_FTP},
{"-i, --include",
"Include protocol response headers in the output",
"Include response headers in output",
CURLHELP_IMPORTANT | CURLHELP_VERBOSE},
{"-k, --insecure",
"Allow insecure server connections",
@ -331,7 +331,7 @@ const struct helptxt helptext[] = {
"Enable Kerberos with security <level>",
CURLHELP_FTP},
{" --libcurl <file>",
"Dump libcurl equivalent code of this command line",
"Generate libcurl code for this command line",
CURLHELP_CURL},
{" --limit-rate <speed>",
"Limit transfer speed to RATE",
@ -339,14 +339,14 @@ const struct helptxt helptext[] = {
{"-l, --list-only",
"List only mode",
CURLHELP_FTP | CURLHELP_POP3 | CURLHELP_SFTP},
{" --local-port <num/range>",
"Force use of RANGE for local port numbers",
{" --local-port <range>",
"Use a local port number within RANGE",
CURLHELP_CONNECTION},
{"-L, --location",
"Follow redirects",
CURLHELP_HTTP},
{" --location-trusted",
"Like --location, and send auth to other hosts",
"Like --location, but send auth to other hosts",
CURLHELP_HTTP | CURLHELP_AUTH},
{" --login-options <options>",
"Server login options",
@ -361,7 +361,7 @@ const struct helptxt helptext[] = {
"Mail to this address",
CURLHELP_SMTP},
{" --mail-rcpt-allowfails",
"Allow RCPT TO command to fail for some recipients",
"Allow RCPT TO command to fail",
CURLHELP_SMTP},
{"-M, --manual",
"Display the full manual",
@ -372,7 +372,7 @@ const struct helptxt helptext[] = {
{" --max-redirs <num>",
"Maximum number of redirects allowed",
CURLHELP_HTTP},
{"-m, --max-time <fractional seconds>",
{"-m, --max-time <seconds>",
"Maximum time allowed for transfer",
CURLHELP_CONNECTION},
{" --metalink",
@ -418,10 +418,10 @@ const struct helptxt helptext[] = {
"List of hosts which do not use proxy",
CURLHELP_PROXY},
{" --ntlm",
"Use HTTP NTLM authentication",
"HTTP NTLM authentication",
CURLHELP_AUTH | CURLHELP_HTTP},
{" --ntlm-wb",
"Use HTTP NTLM authentication with winbind",
"HTTP NTLM authentication with winbind",
CURLHELP_AUTH | CURLHELP_HTTP},
{" --oauth2-bearer <token>",
"OAuth 2 Bearer Token",
@ -451,13 +451,13 @@ const struct helptxt helptext[] = {
"FILE/HASHES Public key to verify peer against",
CURLHELP_TLS},
{" --post301",
"Do not switch to GET after following a 301",
"Do not switch to GET after a 301 redirect",
CURLHELP_HTTP | CURLHELP_POST},
{" --post302",
"Do not switch to GET after following a 302",
"Do not switch to GET after a 302 redirect",
CURLHELP_HTTP | CURLHELP_POST},
{" --post303",
"Do not switch to GET after following a 303",
"Do not switch to GET after a 303 redirect",
CURLHELP_HTTP | CURLHELP_POST},
{" --preproxy [protocol://]host[:port]",
"Use this proxy first",
@ -484,13 +484,13 @@ const struct helptxt helptext[] = {
"Use Basic authentication on the proxy",
CURLHELP_PROXY | CURLHELP_AUTH},
{" --proxy-ca-native",
"Use CA certificates from the native OS for proxy",
"Load CA certs from the OS to verify proxy",
CURLHELP_TLS},
{" --proxy-cacert <file>",
"CA certificate to verify peer against for proxy",
"CA certificates to verify proxy against",
CURLHELP_PROXY | CURLHELP_TLS},
{" --proxy-capath <dir>",
"CA directory to verify peer against for proxy",
"CA directory to verify proxy against",
CURLHELP_PROXY | CURLHELP_TLS},
{" --proxy-cert <cert[:passwd]>",
"Set client certificate for proxy",
@ -505,7 +505,7 @@ const struct helptxt helptext[] = {
"Set a CRL list for proxy",
CURLHELP_PROXY | CURLHELP_TLS},
{" --proxy-digest",
"Use Digest authentication on the proxy",
"Digest auth with the proxy",
CURLHELP_PROXY | CURLHELP_TLS},
{" --proxy-header <header/@file>",
"Pass custom header(s) to proxy",
@ -514,7 +514,7 @@ const struct helptxt helptext[] = {
"Use HTTP/2 with HTTPS proxy",
CURLHELP_HTTP | CURLHELP_PROXY},
{" --proxy-insecure",
"Do HTTPS proxy connections without verifying the proxy",
"Skip HTTPS proxy cert verification",
CURLHELP_PROXY | CURLHELP_TLS},
{" --proxy-key <key>",
"Private key for HTTPS proxy",
@ -523,10 +523,10 @@ const struct helptxt helptext[] = {
"Private key file type for proxy",
CURLHELP_PROXY | CURLHELP_TLS},
{" --proxy-negotiate",
"Use HTTP Negotiate (SPNEGO) authentication on the proxy",
"HTTP Negotiate (SPNEGO) auth with the proxy",
CURLHELP_PROXY | CURLHELP_AUTH},
{" --proxy-ntlm",
"Use NTLM authentication on the proxy",
"NTLM authentication with the proxy",
CURLHELP_PROXY | CURLHELP_AUTH},
{" --proxy-pass <phrase>",
"Pass phrase for the private key for HTTPS proxy",
@ -541,7 +541,7 @@ const struct helptxt helptext[] = {
"Allow security flaw for interop for HTTPS proxy",
CURLHELP_PROXY | CURLHELP_TLS},
{" --proxy-ssl-auto-client-cert",
"Use auto client certificate for proxy (Schannel)",
"Auto client certificate for proxy",
CURLHELP_PROXY | CURLHELP_TLS},
{" --proxy-tls13-ciphers <ciphersuite list>",
"TLS 1.3 proxy cipher suites",
@ -556,7 +556,7 @@ const struct helptxt helptext[] = {
"TLS username for HTTPS proxy",
CURLHELP_PROXY | CURLHELP_TLS | CURLHELP_AUTH},
{" --proxy-tlsv1",
"Use TLSv1 for HTTPS proxy",
"TLSv1 for HTTPS proxy",
CURLHELP_PROXY | CURLHELP_TLS | CURLHELP_AUTH},
{"-U, --proxy-user <user:password>",
"Proxy user and password",
@ -565,7 +565,7 @@ const struct helptxt helptext[] = {
"Use HTTP/1.0 proxy on given port",
CURLHELP_PROXY},
{"-p, --proxytunnel",
"Operate through an HTTP proxy tunnel (using CONNECT)",
"HTTP proxy tunnel (using CONNECT)",
CURLHELP_PROXY},
{" --pubkey <key>",
"SSH Public key filename",
@ -592,13 +592,13 @@ const struct helptxt helptext[] = {
"Use the header-provided filename",
CURLHELP_OUTPUT},
{"-O, --remote-name",
"Write output to a file named as the remote file",
"Write output to file named as remote file",
CURLHELP_IMPORTANT | CURLHELP_OUTPUT},
{" --remote-name-all",
"Use the remote filename for all URLs",
CURLHELP_OUTPUT},
{"-R, --remote-time",
"Set the remote file's time on the local output",
"Set remote file's time on local output",
CURLHELP_OUTPUT},
{" --remove-on-error",
"Remove output file on errors",
@ -610,16 +610,16 @@ const struct helptxt helptext[] = {
"Specify the target for this request",
CURLHELP_HTTP},
{" --resolve <[+]host:port:addr[,addr]...>",
"Resolve the host+port to this address",
"Resolve host+port to address",
CURLHELP_CONNECTION | CURLHELP_DNS},
{" --retry <num>",
"Retry request if transient problems occur",
CURLHELP_CURL},
{" --retry-all-errors",
"Retry all errors (use with --retry)",
"Retry all errors (with --retry)",
CURLHELP_CURL},
{" --retry-connrefused",
"Retry on connection refused (use with --retry)",
"Retry on connection refused (with --retry)",
CURLHELP_CURL},
{" --retry-delay <seconds>",
"Wait time between retries",
@ -631,7 +631,7 @@ const struct helptxt helptext[] = {
"Identity for SASL PLAIN authentication",
CURLHELP_AUTH},
{" --sasl-ir",
"Enable initial response in SASL authentication",
"Initial response in SASL authentication",
CURLHELP_AUTH},
{" --service-name <name>",
"SPNEGO service name",
@ -652,7 +652,7 @@ const struct helptxt helptext[] = {
"SOCKS5 proxy on given host + port",
CURLHELP_PROXY},
{" --socks5-basic",
"Enable username/password auth for SOCKS5 proxies",
"Username/password auth for SOCKS5 proxies",
CURLHELP_PROXY | CURLHELP_AUTH},
{" --socks5-gssapi",
"Enable GSS-API auth for SOCKS5 proxies",
@ -673,7 +673,7 @@ const struct helptxt helptext[] = {
"Trigger 'speed-limit' abort after this time",
CURLHELP_CONNECTION},
{" --ssl",
"Try SSL/TLS",
"Try enabling TLS",
CURLHELP_TLS},
{" --ssl-allow-beast",
"Allow security flaw to improve interop",
@ -688,13 +688,13 @@ const struct helptxt helptext[] = {
"Require SSL/TLS",
CURLHELP_TLS},
{" --ssl-revoke-best-effort",
"Ignore missing/offline cert CRL dist points (Schannel)",
"Ignore missing cert CRL dist points",
CURLHELP_TLS},
{"-2, --sslv2",
"Use SSLv2",
"SSLv2",
CURLHELP_TLS},
{"-3, --sslv3",
"Use SSLv3",
"SSLv3",
CURLHELP_TLS},
{" --stderr <file>",
"Where to redirect stderr",
@ -709,7 +709,7 @@ const struct helptxt helptext[] = {
"Use TCP Fast Open",
CURLHELP_CONNECTION},
{" --tcp-nodelay",
"Use the TCP_NODELAY option",
"Set TCP_NODELAY",
CURLHELP_CONNECTION},
{"-t, --telnet-option <opt=val>",
"Set telnet option",
@ -724,9 +724,9 @@ const struct helptxt helptext[] = {
"Transfer based on a time condition",
CURLHELP_HTTP | CURLHELP_FTP},
{" --tls-max <VERSION>",
"Set maximum allowed TLS version",
"Maximum allowed TLS version",
CURLHELP_TLS},
{" --tls13-ciphers <ciphersuite list>",
{" --tls13-ciphers <list>",
"TLS 1.3 cipher suites to use",
CURLHELP_TLS},
{" --tlsauthtype <type>",
@ -739,19 +739,19 @@ const struct helptxt helptext[] = {
"TLS username",
CURLHELP_TLS | CURLHELP_AUTH},
{"-1, --tlsv1",
"Use TLSv1.0 or greater",
"TLSv1.0 or greater",
CURLHELP_TLS},
{" --tlsv1.0",
"Use TLSv1.0 or greater",
"TLSv1.0 or greater",
CURLHELP_TLS},
{" --tlsv1.1",
"Use TLSv1.1 or greater",
"TLSv1.1 or greater",
CURLHELP_TLS},
{" --tlsv1.2",
"Use TLSv1.2 or greater",
"TLSv1.2 or greater",
CURLHELP_TLS},
{" --tlsv1.3",
"Use TLSv1.3 or greater",
"TLSv1.3 or greater",
CURLHELP_TLS},
{" --tr-encoding",
"Request compressed transfer encoding",
@ -766,7 +766,7 @@ const struct helptxt helptext[] = {
"Details to log in trace/verbose output",
CURLHELP_VERBOSE},
{" --trace-ids",
"Add transfer and connection identifiers to trace/verbose output",
"Transfer + connection ids in verbose output",
CURLHELP_VERBOSE},
{" --trace-time",
"Add time stamps to trace/verbose output",
@ -802,7 +802,7 @@ const struct helptxt helptext[] = {
"Show version number and quit",
CURLHELP_IMPORTANT | CURLHELP_CURL},
{"-w, --write-out <format>",
"Use output FORMAT after completion",
"Output FORMAT after completion",
CURLHELP_VERBOSE},
{" --xattr",
"Store metadata in extended file attributes",