Idea: New julia CLI switches (`-m` and `--pkg`)

pankgeorg
Mon, 15 May 2023 20:37:00 +0000
General Usage

1. -m: shorthand for -e using Module: Module

julia -e "import Pluto; Pluto.run()"

is a pattern I happen to use very often

With this idea it could get converted to

julia -m Pluto

which could even run pluto as-is (invoke the run or serve by default), but it probably makes sense to actually pass some command, like

julia -m Pluto -e "run()"

2. Pkg operations with --pkg

This is usually used when we download a project file from the internet, and we need to prepare our environment, or when we build Dockerfiles
julia --project=some_project_from_colleage -e "import Pkg; Pkg.instantiate(); Pkg.precompile()"

What if we made this look like
julia --project=some_project_from_colleage --pkg=all|instantiate|precompile|resolve|generate

Of course that has some overlap with the previous one, as it could also be written

julia --project=some_project_from_colleage -m Pkg -e "instantiate(); precompile()"

These could even be chained

julia --project=some_project_from_colleage -m Pkg -e "instantiate(); precompile()" -m Pluto -e "run()"

But I think julia --project=some_project_from_colleage --pkg -m Pluto -e "run()" would be nicer. On the other hand, I realize that using Module already runs some code (in the __init__), so packages could hook into the “no -e” -m Module syntax (Genie notoriously runs a lot of code in __init__)

More nice examples:

julia -m Dates -E "now()"
julia -m UUIDs -E "uuid4()"

What do you think? Would these and/or other additions to cli switches make sense?

10 posts - 4 participants