Open jlbosse opened 10 months ago
I think this is possible. And I like this idea! could be supported by adding your change here https://github.com/comonicon/Comonicon.jl/blob/main/src/frontend/cast.jl#L461, please feel free to open a PR for this!
Great, I will try to find some time create a PR for this then!
It would be great if
command_main()
only gets called when the script is run from the command line and not when it isinclude()
ed e.g. in a REPL session. This would allow one to have a julia script that is on one hand usable as a CLI, but on the other hand one can also doinclude(myscript.jl)
in a REPL session or other script and use the functionality defined inmyscript.jl
from there.I suppose wrapping the call in a
if abspath(PROGRAM_FILE) == @__FILE__ command_main() end
would do that trick.