# \`jlpkg\` -- a command line interface to Pkg

**URL:** <https://discourse.julialang.org/t/jlpkg-a-command-line-interface-to-pkg/24077>\
**Category:** Package Announcements\
**Created:** [May 10, 2019, 2:30pm UTC](https://discourse.julialang.org/t/jlpkg-a-command-line-interface-to-pkg/24077 "2019-05-10T14:30:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 10, 2019, 2:30pm UTC](https://discourse.julialang.org/t/jlpkg-a-command-line-interface-to-pkg/24077/1 "2019-05-10T14:30:35Z")

</div>

Hello everyone!

I’d like to announce [`jlpkg`](https://github.com/fredrikekre/jlpkg), a command line interface (CLI) to Julia’s package manager Pkg. `jlpkg` is essentially a wrapper around the [Pkg REPL mode](https://julialang.github.io/Pkg.jl/v1/repl/) so all of you are probably familiar with the commands already.

#### How do I install the CLI?

Installation is as easy as

```bash
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`](https://github.com/fredrikekre/Literate.jl) package:

```bash
$ jlpkg add Literate

```

show the project status

```bash
$ jlpkg st

```

test a package

```bash
$ jpkg test Example

```

add [`Documenter`](https://github.com/JuliaDocs/Documenter.jl) to your docs project

```bash
$ 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`:

```bash
$ jlpkg add Literate > /dev/null

```

or filter `status` output with `grep`

```bash
$ 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`:

```bash
#!/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:

```bash
$ time ./time.sh > /dev/null
real 0m5.051s
user 0m4.896s
sys 0m0.667s

```

and with `--compile=min` you get:

```bash
$ 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!**

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 30, 2020, 1:05pm UTC](https://discourse.julialang.org/t/jlpkg-a-command-line-interface-to-pkg/24077/2 "2020-10-30T13:05:21Z")

</div>

## Quick update with things that has been added since the initial release

### Bash completion

The only thing that I have found annoying when using `jlpkg` compared to the real Pkg REPL is tab-completion. `jlpkg` now provides Bash completion. It completes the CLI switches, the Pkg REPL commands (including options), and also some more fancy things. Here are some examples:

After the project flag, the completion filters out any paths that is not a directory or a toml file:

```bash
$ ls
A file.jl Project.toml

$ jlpkg --project=<TAB>
A/ Project.toml

```

The `add` command completes packages found in installed registries:

```bash
$ jlpkg add Exa<TAB>
ExactDiagonalization ExactPredicates ExactReals ExactWrightFisher Example

```

Any command that acts on packages in the current project completes only those, in project/manifest mode as appropriate:

```bash
$ pkg status <TAB>
Example JSON     

$ pkg status --manifest <TAB>
Dates Example JSON Mmap Parsers Printf Unicode

```

The completion has been written with compatibility with Bash 3 in mind, to properly function on macOs too.

### Alternative installation methods

See the [README](https://github.com/fredrikekre/jlpkg/blob/master/README.md#installation), in addition to installing from Julia you there are now two additional methods:

1. Tarball download: You can now download `jlpkg` from GitHub releases and unpack in some folder on `PATH`. With this methods you don’t have to start Julia nor add the `jlpkg` Julia package:

2. `asdf` package manager: You can install and update `jlpkg` using the [`asdf` version manager](https://asdf-vm.com/) using the [`asdf-jlpkg` plugin](https://github.com/fredrikekre/asdf-jlpkg). See the [plugin README](https://github.com/fredrikekre/asdf-jlpkg/blob/master/README.md) for details. This is probably mostly useful if you use `asdf` for other things, for example for managing Julia version.

### New CLI options

There are some nice new CLI options:

- The `--julia` flag can be used for specifying the Julia binary. This is sometimes useful if you want to repeat something for multiple Julia versions, for example:

- The `--offline` flag can be used to enable Pkg’s [offline mode](https://github.com/JuliaLang/Pkg.jl/blob/dc8383a60e4aba202d486859fd3754f2aa5b77d9/src/Pkg.jl#L421-L436).
