Open mauro3 opened 7 years ago
I'll note that Rust does this by having a src/bin
folder under which every file is a runnable artifact which can be run with cargo run --bin <name-of-file-without-ext>
.
Not sure what you'd do with runnables that consist of multiple files though.
I like the idea of having a /src
directory with shared code and a /run
directory with code used at runtime (to run a script, launch an app, or whatever).
However I think we need to allow multiple entry points in the run directory, so Pkg.run("SomePkg")
doesn't seem quite correct.
Also, if I could register with the package manager certain files in the /run
directory, say /run/tool.jl
, then it could create a shell script or shortcut in ~/bin
or somewhere so that at the command line I can just type tool args...
to launch my awesome Julia command line tool, that would be awesome!
(even the package manager could have some command line tools, like julia-pkg
similar to pip
, so that non-programmers could install julia, type julia-pkg add SomeAwesomeProgram
and be able to use said program immediately from the command line).
EDIT: I just realized that Pkg.build()
could do the step of installation. Perhaps there could also be a Pkg.install()
command which runs an installation script (perhaps even performing Pkg.add()
and Pkg.build()
if necessary).
However I think we need to allow multiple entry points in the run directory, so Pkg.run("SomePkg") doesn't seem quite correct.
What about a way to set keyword args? Pkg.run("SomePkg",save_plots=false)
? Then command line:
julia-pkg run SomePkg save_plots=false save_jld=true
I was thinking Pkg.run("SomePkg", "Tool1", args...)
and Pkg.run("SomePkg", "Tool2", args..)
since there might be multiple, disjoint "programs" per package.
A package might want to specify a default "program" - I'm not sure.
@andyferris The way Rust handles that is when there is only one executable artefact, you need not specify the name of an artefact.
So, for a run
folder that only contained some_program.jl
, then Pkg.run("SomePkg" [, ...])
would do the same thing as Pkg.run("SomePkg", "some_program" [, ...])
.
Plus, the name of the artefact can be more descriptive than simply main
, or whatever.
Over in discourse it was discussed to distinguish between "runnable packages" (called projects in that thread) and "library packages" (called packages). The suggestion which gathered the most likes was not to distinguish between projects and packages, but instead to "standardize where to put runnable scripts into packages as we know them now. Say a folder
run/
orscripts/
and the main program would berun/main.jl
. Pure "Projects" would have an emptysrc/
folder and fullrun/
folder and vice versa (most would have a bit of both). Similar toPkg.test("SomePkg")
we could have aPkg.run("SomePkg")
torun run/main.jl
." Also a command-line option could be good, sayjulia --run SomePkg
.(I haven't followed this Julep too closely, please close this issue if this is in it already. Or let me know if this should be posted over in Julia itself.)