argparse icon indicating copy to clipboard operation
argparse copied to clipboard

cli:run_options/0 is not a subtype of argparse:parser_options/0

Open zerth opened this issue 1 year ago • 0 comments

cli:run/2 accepts a run_options() which is later passed directly to functions of argparse expecting a parser_options(). This leads to dialyzer errors when passing keys which are only allowed in run_options(); e.g., error.

Dialyzing the calc example app amended to include the following (in a thingy.erl module):

main(Args) ->
    cli:run(Args, #{error => error, progname => "calc"}).

results in:

thingy.erl:5:1: Function main/1 has no local return
thingy.erl:6:19: The call cli:run
         (Args :: any(),
          #{error => error, progname => "calc"}) will never return since it differs in the 2nd argument from the success typing arguments:
         (any(),
          #{'error' => 'ok', _ => _})

zerth avatar Jul 11 '22 18:07 zerth