Interpolate pkg string a la pkg"status $x"

x = "BenchmarkTools" # just an example
pkg"status $x" # what I want but doesn't work

Looking at the definition of @pkg_str I figured I can do

x = "BenchmarkTools"
s = "status $x"
Pkg.REPLMode.do_cmd(Pkg.REPLMode.minirepl[], s; do_rethrow=true)

which works but is arguably ugly.

Is there a nice way that I’m missing?

Ok, there is also Pkg.status("BenchmarkTools"). But nonetheless, shouldn’t it be possible to interpolate values into a pkg string?

You can do

> x = "BenchmarkTools";

> Pkg.REPLMode.pkgstr("status $x")

This has nothing to do with “pkg string” but with string macros in general.

3 Likes