-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to use the functionalities within a REPL environment? #63
Comments
In future you will be able to use |
For me it works to statically compile a file that uses ArgParse. With the content of example.jl being using ArgParse
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
# initialize the settings (the description is for the help screen)
s = ArgParseSettings(description = "Example 1 for argparse.jl: minimal usage.")
@add_arg_table s begin
"--opt1" # an option (will take an argument)
"--opt2", "-o" # another option, with short form
"arg1" # a positional argument
end
parsed_args = parse_args(ARGS, s) # the result is a Dict{String,Any}
println("Parsed args:")
for (key,val) in parsed_args
println(" $key => $(repr(val))")
end
return 0
end and in the Julia REPL using PackageCompiler
build_executable("example.jl", "example") I get an executable that produces (in a shell) ./example -o bla
Parsed args:
arg1 => nothing
opt1 => nothing
opt2 => "bla" |
Yes I confirm no issues with |
I believe that between the fix in #88 and the compilation examples provided in this thread, this issue can be considered resolved. Otherwise, please comment and I'll reopen. |
This library is excellent but I just realized that it seems to be really inconvenient to run Julia as a traditional command-line program (i.e. Julia is really tailored towards REPL usage). It seems that as soon as the process exits, the compilation results will be lost and the next invocation of
julia
will need to perform the compilation all over again? The startup time will be very long compared with just loading the module in the REPL and then calling its functions afterwards.However, if I call functions within a REPL, I can't really perform argument parsing with flags and show help messages, in the style of a traditional command line program. I can only call functions with the correct order of arguments.
I just wonder if there's a way to also use this library within a REPL environment? It seems to be really a pity that one cannot enjoy both speed and argument-parsing convenience with Julia until binary executables can be produced. Am I understanding the situation correctly?
The text was updated successfully, but these errors were encountered: