Hi Uthsav,

Can you give some more details about what you're actually trying to do?

If you're simply trying to break up your files, it should work fine.

$ julia argparse_example3.jl --opt1 1 2 3
Parsed args:
  arg1  =>  Any["2","3"]
  karma  =>  0
  arg2  =>  Any["no_arg_given"]
  opt1  =>  1

$ echo 'include("argparse_example3.jl")' > arg_test.jl
$ julia arg_test.jl --opt1 1 2 3
Parsed args:
  arg1  =>  Any["2","3"]
  karma  =>  0
  arg2  =>  Any["no_arg_given"]
  opt1  =>  1

On the other hand, if you're running from the REPL... well, first, I'm not
sure that makes much sense.  `ArgParse` is meant for parsing command line
arguments, and it's not possible right now to do that from the REPL:

$ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.3-pre+6 (2015-12-11 00:38 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit adffe19* (28 days old release-0.4)
|__/                   |  x86_64-apple-darwin14.5.0

julia> include("argparse_example3.jl")
required argument arg1 was not provided
usage: argparse_example3.jl [--opt1 [OPT1]] [-k] arg1 arg1 [arg2...]
$

The best I could come up with was

$ julia -e 'include("argparse_example3.jl")' -- --opt1 1 2 3
Parsed args:
  arg1  =>  Any["2","3"]
  karma  =>  0
  arg2  =>  Any["no_arg_given"]
  opt1  =>  1

Which is doing essentailly the same thing as the previous example.

(BTW, you might find DocOpt.jl to be a useful substitute.)

Cheers,
   Kevin


On Thu, Jan 7, 2016 at 4:16 PM, Uthsav Chitra <[email protected]>
wrote:

> (Not sure how to edit my message) Actually, I ran it how you did and it
> worked fine. But I'm still not sure why it won't run when I use
> include("arg.jl").
>
>
> On Thursday, January 7, 2016 at 7:09:47 PM UTC-5, Uthsav Chitra wrote:
>>
>> I opened Julia in Terminal, made a file with that text called 'arg.jl',
>> and ran
>>
>> include("arg.jl").
>>
>> On Thursday, January 7, 2016 at 4:34:00 PM UTC-5, Kevin Squire wrote:
>>>
>>> Hello Uthsav,
>>>
>>> Works for me:
>>>
>>> $ julia0.3 argparse_example3.jl --opt1 1 2 3
>>> Parsed args:
>>>   arg1  =>  {"2","3"}
>>>   karma  =>  0
>>>   arg2  =>  {"no_arg_given"}
>>>   opt1  =>  1
>>>
>>> How are you trying to run that code?
>>>
>>> On Thu, Jan 7, 2016 at 12:36 PM, Uthsav Chitra <[email protected]>
>>> wrote:
>>>
>>>> I'm using Julia v0.3.9 right now. I recently updated all my packages (I
>>>> haven't opened Julia in a couple months), including ArgParse. The macro
>>>> @add_arg_table isn't recognized though. In particular, I tried running
>>>> example code here
>>>> <https://github.com/carlobaldassi/ArgParse.jl/blob/master/examples/argparse_example3.jl>,
>>>> but I get the following error:
>>>>
>>>> *ERROR: @add_arg_table not defined*
>>>>
>>>> * in include at
>>>> /Applications/Julia-0.3.9.app/Contents/Resources/julia/lib/julia/sys.dylib*
>>>>
>>>> * in include_from_node1 at
>>>> /Applications/Julia-0.3.9.app/Contents/Resources/julia/lib/julia/sys.dylib*
>>>>
>>>> *while loading /Users/Uthsav/Desktop/Walking The Interactome
>>>> Work/arg.jl, in expression starting on line 42*
>>>>
>>>>
>>>> This is essentially the problem I'm having in my own code. I looked but
>>>> couldn't find any information about this besides what it says on the
>>>> Github, which is that the macro @add_arg_table should still work. Any help
>>>> would be greatly appreciated. Thanks a lot!
>>>>
>>>
>>>

Reply via email to