carlobaldassi/ArgParse.jl

as_symbols not working on :_COMMAND_ entry

mattuntergassmair opened this issue · 3 comments

keys of parse_args(s, as_symbols=true) are strings but should be symbols

I tried a few things but I can't reproduce this problem. Can you provide a test case so that I can add it to the tests before merging #85?

using ArgParse

ARGS = split("say hello --to world")

function parse_commandline()
    s = ArgParseSettings()

    @add_arg_table s begin
        "say"
            action = :command
    end

    @add_arg_table s["say"] begin
        "what"
            help = "a positional argument"
            required = true
        "--to"
            help = "an option with an argument"
    end

    return parse_args(ARGS, s, as_symbols=true)
end

parsed_args = parse_commandline()
println("Parsed args:")
for (arg,val) in parsed_args[:say]
    @show typeof(arg)  # should be symbol
    println("  $arg  =>  $val")
end

Ok, added a test case similar to the above snippet.