-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugIssue is reported as a bugIssue is reported as a bugteam:VMAssigned to OTP team VMAssigned to OTP team VM
Description
Describe the bug
since 1aa91e7 argparse:format_help/1 will crash when its Options contain a 'hidden' command.
invocation of argparse:run/3 with a 'hidden' command in Args will -- when argparse:parse/3 fails -- print the error and then an exception message (instead of the related help).
To Reproduce
Erlang/OTP 27 [erts-15.1.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns] [dtrace] [sharing-preserving]
Eshell V15.1.2 (press Ctrl+G to abort, type help(). for help)
1> Cmd = #{commands => #{"foo" => #{help => hidden, arguments => [#{name => x, help => "the X", type => integer}]}}}.
#{commands =>
#{"foo" =>
#{arguments => [#{name => x,type => integer,help => "the X"}],
help => hidden}}}
2> argparse:run(["foo", "NaN"], Cmd, #{}).
error: erl foo: invalid argument for x: NaN is not an integer
** exception error: bad generator hidden
in function argparse:'-format_help/2-lc$^1/1-1-'/3 (argparse.erl, line 1652)
in call from argparse:format_help/2 (argparse.erl, line 1652)
in call from argparse:run/3 (argparse.erl, line 782)
3>
Expected behavior
Erlang/OTP 26 [erts-14.2.5.4] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns] [dtrace] [sharing-preserving]
Eshell V14.2.5.4 (press Ctrl+G to abort, type help(). for help)
1> Cmd = #{commands => #{"foo" => #{help => hidden, arguments => [#{name => x, help => "the X", type => integer}]}}}.
#{commands =>
#{"foo" =>
#{arguments => [#{name => x,type => integer,help => "the X"}],
help => hidden}}}
2> argparse:run(["foo", "NaN"], Cmd, #{}).
error: erl foo: invalid argument for x: NaN is not an integer
Usage:
erl foo <x>
Arguments:
x the X (int)
Affected versions
Metadata
Metadata
Assignees
Labels
bugIssue is reported as a bugIssue is reported as a bugteam:VMAssigned to OTP team VMAssigned to OTP team VM