How run script in Juno with parameters?

Is possible to run Julia file in Juno , as running it as command line passing it some arguments? i don’t know where i can specify arguments in running a script in Juno …

This does not directly answer your question, but I would just separate argument parsing from the function that actually does the work, and just call the latter.

1 Like

This does not directly answer your question too, but could help:

I use Juno in Atom. For Atom, there is a package called script https://atom.io/packages/script , and it is possible with the package to run a script with command line parameters. I have used it to pass arguments to a Python script, but it will run a Julia script just as well (I have tested on a simple Julia script, however without arguments).

There’s an Arguments option under Settings -> Packages -> julia-client -> Settings -> Julia Options:

1 Like

I have found now this option, but I don’s see where can I enter the script arguments.
2020-03-02 13_40_24-REPL — C___MyOwnDocs_SoftwareDevelopment_JulTests — Atom

That’s an Atom bug – just click on the zero-height textbox.

Damn, and who would have thought that that line was the field where to insert the arguments … in fact it works!
Thanks.

Oh yes, i understand what you mean … but i have a script running in this way:

julia search.jl -w "word1 word2 word3" -e 20

and i would see in REPL of juno, debugging, if argument to my script are correctly passed to function,
because before to pass to it, they must be checked, perhaps modified, ecc ecc

I also find this way, because it is not so good the args parameterer passing in Juno ( i have other IDE for Python, for example, that memorize argument given for a string and simply disactive/active arguments … better than what i see in Juno).
I put in the start of my script this code to manipolate ARGS array

if false
  empty!(ARGS)
  push!(ARGS, "-w")
  push!(ARGS, "anima corpo sangue")
  push!(ARGS, "-e")
  push!(ARGS, "20")
end

and if i want to test from Juno, i set to true the if, so Julia add to ARG the argument as they come from command line … ok fine. :slight_smile:

All you get from the command line is ARGS. You can organize the whole logic of parsing that into a function

function parse_args(args)
    ...
end

and test it with

parse_args(["-w", "word1 word2 word3", "-e", "20"])

then just use it as parse_args(ARGS).

Thanks, ok, i will do so!

Do you happen to know an Atom Issue I can follow for this? I’ve had this problem for quite a while now too.

I couldn’t find one, actually. Would be good to open an issue here, but I can’t actually repro the bug right now…