Hello everyone!
I’d like to announce jlpkg
, a command line interface (CLI) to Julia’s package manager Pkg. jlpkg
is essentially a wrapper around the Pkg REPL mode so all of you are probably familiar with the commands already.
How do I install the CLI?
Installation is as easy as
pkg> add jlpkg
julia> import jlpkg; jlpkg.install()
This will place an executable in ~/.julia/bin
by default, so make sure that is on your PATH
, or alternatively, symlink to it from a folder that is in your PATH
. The installation is fairly customizable via keyword arguments, so make sure to check out the docstring for the jlpkg.install
function.
How do I use the CLI?
Once the installation is done you can start using it. Available commmands can be listed with jlpkg --help
. For example, add the Literate
package:
$ jlpkg add Literate
show the project status
$ jlpkg st
test a package
$ jpkg test Example
add Documenter
to your docs project
$ jlpkg --project=docs add Documenter
etc.
Why should I use the CLI instead of the Pkg REPL mode?
The Pkg REPL mode is great, I use it all the time, but sometimes it is just quicker to grab another tool from the toolbox. If you just need to run some quick Pkg commands it can be much quicker to call jlpkg cmd
instead of (i) start julia (ii) enter the Pkg REPL (iii) enter cmd
.
Since jlpkg
is run from the shell you can utilize other cool things, like redirecting output to /dev/null
:
$ jlpkg add Literate > /dev/null
or filter status
output with grep
$ jlpkg st | grep Ex
[7876af07] Example v0.5.1
etc.
It is also worth noting that, by default, the CLI runs in interpreted julia mode (--compile=min
), which for this case turns out to be much faster. Compare for example the following script time.sh
:
#!/bin/sh
jlpkg add Example DataFrames JSON StaticArrays
jlpkg rm Example DataFrames JSON StaticArrays
jlpkg dev Literate
jlpkg rm Literate
with default julia settings you get:
$ time ./time.sh > /dev/null
real 0m5.051s
user 0m4.896s
sys 0m0.667s
and with --compile=min
you get:
$ time ./time.sh > /dev/null
real 0m1.033s
user 0m1.073s
sys 0m0.636s
which is almost 5 times faster. So if all you want to do is to check the status
of your project, jlpkg st
is much faster compared to julia -e 'using Pkg; Pkg.status()'
, or (i) open julia, (ii) enter the repl mode, (iii) run the command, (iv) exit julia.
I hope that some of you might find this tool useful and want to try it out. Please get back to me with any feedback, comments or issues, either here or on the GitHub repository. Happy package managing!