Recover status of a package from julia

I would like to recover a string containing the status of a given package (v.2.2.2 in the example) but I am only able to print it out

julia> Pkg.status("CuArrays")
Project BTL v0.1.0
Status `~/Project/BTL.jl/Project.toml`
  [3a865a2d] CuArrays v2.2.2

Is there a simple way to do it ?


Would something along those lines work for you?

original_stdout = stdout
(rd, wr)  = redirect_stdout()
s = readline(rd)


1 Like

Thanks a lot, this will do.
I was wondering if I missed some obvious solution.

Actually this only returns the first line.
I wonder why there is no IO first argument as it is often the case with Julia functions.

In that case you can just use readlines(rd) to get an array of strings.

But after a bit of tinkering around, I think this here suits you better than my solution above:

io = IOBuffer(read=true, write=true)
Pkg.status("CuArrays", io=io)
s = String(take!(io))
1 Like

Yes, much nicer !

I wonder why the help does not mention the io argument

help?> Pkg.status
  Pkg.status([pkgs...]; mode::PackageMode=PKGMODE_PROJECT, diff::Bool=false)

Than you again !

It is something general, not only for status()