DocOpt.jl icon indicating copy to clipboard operation
DocOpt.jl copied to clipboard

Chaging no-positional arguments order doesn't work

Open ceandrade opened this issue 5 years ago • 0 comments

Assume the very simple example:

import DocOpt
doc = """
Usage:
  test_docopt_order.jl -a <arg_a> -b <arg_b>

Options:

    -a <arg_a>  Argument A.
    -b <arg_b>  Argument B.
"""
args = DocOpt.docopt(doc)
@show args

Calling the script with the proposed order works fine:

$ julia docopt_test.jl -a aaaa -b bbbb
args = Dict{String,Any}("-a" => true,"<arg_a>" => "aaaa","-b" => true,"<arg_b>" => "bbbb")

i.e., -a gives us "<arg_a>" => "aaaa" and -b gives us "<arg_b>" => "bbbb".

Now, if we invert the order, things get messy:

$ julia docopt_test.jl -b bbbb -a aaaa
args = Dict{String,Any}("-a" => true,"<arg_a>" => "bbbb","-b" => true,"<arg_b>" => "aaaa")

Note that docopt parse <arg_a> as "bbbb" and <arg_b> as "aaaa".

In other words, it looks like docopt only consider positional arguments.

Julia Version 1.4.0 (2020-03-21) "DocOpt" => v"0.4.0"

ceandrade avatar Nov 06 '20 20:11 ceandrade