Skip to content

Chaging no-positional arguments order doesn't work #31

@ceandrade

Description

@ceandrade

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions