# ArgParse error "too many arguments"

**URL:** <https://discourse.julialang.org/t/argparse-error-too-many-arguments/59764>\
**Category:** General Usage\
**Created:** [April 22, 2021, 12:32am UTC](https://discourse.julialang.org/t/argparse-error-too-many-arguments/59764 "2021-04-22T00:32:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hei06j](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hei06j/32/20360_2.png) [@hei06j](https://discourse.julialang.org/u/hei06j)\
**Post date:** [April 22, 2021, 12:32am UTC](https://discourse.julialang.org/t/argparse-error-too-many-arguments/59764/1 "2021-04-22T00:32:42Z")

</div>

Hi,

I am trying to use ArgParse to read options from command line. It works when I have three options, but when I add another option it throws “too many argument” error.

```julia
using ArgParse
function parse_commandline()
    s = ArgParseSettings()
    @add_arg_table s begin
        "--opt1"
        "--opt2"
        "--opt3"
        "--opt4"
    end
    return parse_args(s)
end
parsed_args = parse_commandline()

```

```julia
ERROR: LoadError: ArgParseError("too many arguments")
Stacktrace:
  [1] argparse_error(x::Any)
    @ ArgParse ~/.julia/packages/ArgParse/bylyV/src/parsing.jl:9
  [2] parse_arg!(state::ArgParse.ParserState, settings::ArgParseSettings)
    @ ArgParse ~/.julia/packages/ArgParse/bylyV/src/parsing.jl:918
  [3] parse_args_unhandled(args_list::Vector{T} where T, settings::ArgParseSettings, truncated_shopts::Bool)
    @ ArgParse ~/.julia/packages/ArgParse/bylyV/src/parsing.jl:632
  [4] parse_args_unhandled(args_list::Vector{T} where T, settings::ArgParseSettings)
    @ ArgParse ~/.julia/packages/ArgParse/bylyV/src/parsing.jl:595
  [5] parse_args(args_list::Vector{T} where T, settings::ArgParseSettings; as_symbols::Bool)
    @ ArgParse ~/.julia/packages/ArgParse/bylyV/src/parsing.jl:469
  [6] parse_args(args_list::Vector{T} where T, settings::ArgParseSettings)
    @ ArgParse ~/.julia/packages/ArgParse/bylyV/src/parsing.jl:466
  [7] parse_args(settings::ArgParseSettings; kw::Any)
    @ ArgParse ~/.julia/packages/ArgParse/bylyV/src/parsing.jl:421
  [8] parse_args(settings::ArgParseSettings)
    @ ArgParse ~/.julia/packages/ArgParse/bylyV/src/parsing.jl:421
  [9] parse_commandline()
    @ Main ~/Documents/repositories/local/using ArgParse.jl:10
 [10] top-level scope

```

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [April 23, 2021, 11:44am UTC](https://discourse.julialang.org/t/argparse-error-too-many-arguments/59764/2 "2021-04-23T11:44:30Z")

</div>

Works for me (ArgParse version 1.1.4, Julia version 1.6.0):

```julia
$ julia -qie '' -- --opt1=hello
julia> using ArgParse

julia> function parse_commandline()
           s = ArgParseSettings()
           @add_arg_table s begin
               "--opt1"
               "--opt2"
               "--opt3"
               "--opt4"
           end
           return parse_args(s)
       end
parse_commandline (generic function with 1 method)

julia> parsed_args = parse_commandline()
Dict{String, Any} with 4 entries:
  "opt3" => nothing
  "opt4" => nothing
  "opt1" => "hello"
  "opt2" => nothing

```

---

<div class="post-metadata">

**Author:** ![hei06j](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hei06j/32/20360_2.png) [@hei06j](https://discourse.julialang.org/u/hei06j)\
**Post date:** [April 26, 2021, 3:28am UTC](https://discourse.julialang.org/t/argparse-error-too-many-arguments/59764/3 "2021-04-26T03:28:23Z")

</div>

Thanks @fredrikekre, I tried to run the script from the command line and it works, but running in IDE still fails.
