Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
6135-argparse-Correct-argparse-tuple-help-docs....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 6135-argparse-Correct-argparse-tuple-help-docs.patch of Package erlang
From 8df095d9d5b6971c595209139976ad4bd3486643 Mon Sep 17 00:00:00 2001 From: Johannes Christ <jc@jchri.st> Date: Sun, 7 Jan 2024 14:26:19 +0100 Subject: [PATCH] argparse: Correct argparse tuple help docs The second argument must not be a string as-is. Add a testcase to validate that it throws a validation error. --- lib/stdlib/doc/src/argparse.xml | 7 ++++--- lib/stdlib/test/argparse_SUITE.erl | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/stdlib/doc/src/argparse.xml b/lib/stdlib/doc/src/argparse.xml index 136e174a8b..7c77bbbdc1 100644 --- a/lib/stdlib/doc/src/argparse.xml +++ b/lib/stdlib/doc/src/argparse.xml @@ -199,9 +199,10 @@ cli() -> <desc> <p>User-defined help template to print in the command usage. First element of a tuple must be a string. It is printed as a part of the usage header. Second - element of the tuple can be either a string printed as-is, a list - containing strings, <c>type</c> and <c>default</c> atoms, or a user-defined - function that must return a string.</p> + element of the tuple can be either a list containing strings, <c>type</c> + and <c>default</c> atoms, or a user-defined function that must return a + string. A plain string should be wrapped as a list such as + <c>["string is nested"]</c>.</p> </desc> </datatype> diff --git a/lib/stdlib/test/argparse_SUITE.erl b/lib/stdlib/test/argparse_SUITE.erl index 21a0b455de..f25b3cc5d7 100644 --- a/lib/stdlib/test/argparse_SUITE.erl +++ b/lib/stdlib/test/argparse_SUITE.erl @@ -999,6 +999,9 @@ validator_exception(Config) when is_list(Config) -> argparse:validate(#{arguments => [#{name => one, required => ok}]})), ?assertException(error, {argparse, argument, Prg, help, _}, argparse:validate(#{arguments => [#{name => one, help => ok}]})), + %% tuple form of help must not have string as second argument + ?assertException(error, {argparse, argument, Prg, help, _}, + argparse:validate(#{arguments => [#{name => one, help => {"one", "1"}}]})), %% broken commands try argparse:help(#{}, #{progname => 123}), ?assert(false) catch error:badarg:Stack -> -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor