curl: --help [option] displays documentation for given cmdline option

Since the documentation text blob might be gzipped, it needs to search
for what to output in a streaming manner. It then first searches for
"\nALL OPTIONS".

Then, it looks for the start to display at "\n    -[option]" and stops
again at "\n    -". Except for the last option in the man page, which
ends at "\nFILES" - the subtitle for the section following all options
in the manpage.

Test 1707 to 1710 verify

Closes #13997
This commit is contained in:
Daniel Stenberg 2024-08-03 20:24:12 +02:00
parent 9b1e4b4632
commit 9a0cf56471
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
22 changed files with 794 additions and 344 deletions

View file

@ -148,7 +148,6 @@
18. Command line tool
18.1 sync
18.2 glob posts
18.3 -h option
18.4 --proxycommand
18.5 UTF-8 filenames in Content-Disposition
18.6 Option to make -Z merge lined based outputs on stdout
@ -1037,12 +1036,6 @@
Globbing support for -d and -F, as in 'curl -d "name=foo[0-9]" URL'.
This is easily scripted though.
18.3 -h option
Support "curl -h --insecure" etc to output the manpage section for the
--insecure command line option in the terminal. Should be possible to work
with either long or short versions of command line options.
18.4 --proxycommand
Allow the user to make curl run a command and use its stdio to make requests

View file

@ -24,3 +24,5 @@ clean option state, except for the options that are global. Global options
retain their values and meaning even after --next.
The following options are global: `%GLOBALS`.
# ALL OPTIONS

View file

@ -2,7 +2,7 @@
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Long: help
Arg: <category>
Arg: <subject>
Short: h
Help: Get help for commands
Category: important curl
@ -12,15 +12,28 @@ See-also:
- verbose
Example:
- --help all
- --help --insecure
- --help -f
---
# `--help`
Usage help. List all curl command line options within the given **category**.
Usage help. Provide help for the subject given as an optional argument.
If no argument is provided, curl displays the most important command line
arguments.
For category **all**, curl displays help for all options.
The argument can either be a **category** or a **command line option**. When a
category is provided, curl shows all command line options within the given
category. Specify category `all` to list all available options.
If **category** is specified, curl displays all available help categories.
If `category` is specified, curl displays all available help categories.
If the provided subject is instead an existing command line option, specified
either in its short form with a single dash and a single letter, or in the
long form with two dashes and a longer name, curl displays a help text for
that option in the terminal.
The help output is extensive for some options.
If the provided command line option is not known, curl says so.