Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
7098-handle-binary-command-help-correctly.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 7098-handle-binary-command-help-correctly.patch of Package erlang
From 536744af7478eabcae1cdd2df65b3456553cc831 Mon Sep 17 00:00:00 2001 From: Julian Doherty <julian@juliandoherty.com> Date: Sat, 12 Oct 2024 15:31:08 +1100 Subject: [PATCH 1/3] handle binary command help correctly --- lib/stdlib/src/argparse.erl | 5 ++++- lib/stdlib/test/argparse_SUITE.erl | 30 +++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/stdlib/src/argparse.erl b/lib/stdlib/src/argparse.erl index 3536bec696..93fbaa3b49 100644 --- a/lib/stdlib/src/argparse.erl +++ b/lib/stdlib/src/argparse.erl @@ -1661,7 +1661,10 @@ collect_options(CmdName, Command, [Cmd|Tail], Args) -> %% gets help for sub-command get_help(Command, []) -> - maps:get(help, Command, ""); + case maps:get(help, Command, "") of + Help when is_binary(Help) -> unicode:characters_to_list(Help); + Help -> Help + end; get_help(Command, [Cmd|Tail]) -> Sub = maps:get(commands, Command), SubCmd = maps:get(Cmd, Sub), diff --git a/lib/stdlib/test/argparse_SUITE.erl b/lib/stdlib/test/argparse_SUITE.erl index f0cd7c39f7..01f39ef540 100644 --- a/lib/stdlib/test/argparse_SUITE.erl +++ b/lib/stdlib/test/argparse_SUITE.erl @@ -43,6 +43,7 @@ proxy_arguments/0, proxy_arguments/1, usage/0, usage/1, + usage_help_binary/0, usage_help_binary/1, usage_required_args/0, usage_required_args/1, usage_template/0, usage_template/1, usage_args_ordering/0, usage_args_ordering/1, @@ -72,7 +73,7 @@ groups() -> very_short, multi_short, proxy_arguments ]}, {usage, [parallel], [ - usage, usage_required_args, usage_template, usage_args_ordering, + usage, usage_help_binary, usage_required_args, usage_template, usage_args_ordering, parser_error_usage, command_usage, usage_width ]}, {validator, [parallel], [ @@ -815,6 +816,33 @@ usage(Config) when is_list(Config) -> #{progname => "erl", command => ["status", "crawler"]}))), ok. +usage_help_binary() -> + [{doc, "Test binary command help string"}]. + +usage_help_binary(Config) when is_list(Config) -> + Cmd2 = #{arguments => [#{ + name => shard, + type => integer, + default => 0, + help => <<"help binary for shard">>}], + commands => #{"somecommand" => #{ help => <<"help binary for somecommand">> }}, + help => "help binary for command" + }, + + Expected = "Usage:\n" + " erl {somecommand} <shard>\n" + "\n" + "help binary for command\n" + "\n" + "Subcommands:\n" + " somecommand help binary for somecommand\n" + "\n" + "Arguments:\n" + " shard help binary for shard (int), default: 0\n", + + ?assertEqual(Expected, + unicode:characters_to_list(argparse:help(Cmd2, #{}))). + usage_required_args() -> [{doc, "Verify that required args are printed as required in usage"}]. -- 2.43.0
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