From 5fed917a66e211f10923af17a9a1e73ff195dfa5 Mon Sep 17 00:00:00 2001 From: John Haugabook Date: Sat, 2 Aug 2025 18:09:31 -0400 Subject: [PATCH] add documentation and test * cmd documentation for cheat-sheet * help.md: document cheat-sheet Add documentation for cheat-sheet argument. * curl: add line on cheat-sheet * help.c: make test for cheat-sheet * help.c: add cheat-sheet test Test to verify no error with --help cheat-sheet argument. --- docs/cmdline-opts/help.md | 8 +++++--- src/tool_help.c | 1 + tests/data/Makefile.am | 2 +- tests/data/test1461 | 1 + tests/data/test1711 | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 tests/data/test1711 diff --git a/docs/cmdline-opts/help.md b/docs/cmdline-opts/help.md index 122c55cd43..a3d9fe96e0 100644 --- a/docs/cmdline-opts/help.md +++ b/docs/cmdline-opts/help.md @@ -23,11 +23,13 @@ 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. -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. +The argument can either be a **category**, a **command line option**, or +**cheat-sheet**. 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 `cheat-sheet` is specified, curl displays a helpful cheat sheet. 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 diff --git a/src/tool_help.c b/src/tool_help.c index f146d51650..5618ab5fb5 100644 --- a/src/tool_help.c +++ b/src/tool_help.c @@ -233,6 +233,7 @@ void tool_help(const char *category) "Use \"--help all\" to list all options" #ifdef USE_MANUAL "\nUse \"--help [option]\" to view documentation for a given option" + "\nUse \"--help cheat-sheet\" to output a helpful cheat sheet" #endif ; puts("Usage: curl [options...] "); diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index a0a7879660..b9bc7213c4 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -226,7 +226,7 @@ test1670 test1671 \ test1680 test1681 test1682 test1683 \ \ test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \ -test1708 test1709 test1710 \ +test1708 test1709 test1710 test1711 \ \ test1800 test1801 \ \ diff --git a/tests/data/test1461 b/tests/data/test1461 index f1c481ec65..4cf06f5efb 100644 --- a/tests/data/test1461 +++ b/tests/data/test1461 @@ -55,6 +55,7 @@ output, pop3, post, proxy, scp, sftp, smtp, ssh, telnet, tftp, timeout, tls, upload, verbose. Use "--help all" to list all options Use "--help [option]" to view documentation for a given option +Use "--help cheat-sheet" to output a helpful cheat sheet diff --git a/tests/data/test1711 b/tests/data/test1711 new file mode 100644 index 0000000000..8c299063cc --- /dev/null +++ b/tests/data/test1711 @@ -0,0 +1,34 @@ + + + +curl + + + +# +# Client-side + + +manual + + +none + + + +Verify curl -h cheat-sheet + + + +-h cheat-sheet + + + +# +# Verify no error + + +0 + + +