It would be nice to make it easy to capture Pkg3 output to a stream if desired, instead of always printing to stdout/stderr. This is especially useful for things like IJulia and IDE environments.
There seem to be some haphazard attempts at this in the source code, but it would be nice to see a more consistent use of an io::IO argument in all functions that do I/O, e.g. in the Display module.
By the way, I notice that there is actually a print_diff(io, x) method, but it appears to be buggy: it ignores its io argument and just prints to stdout.
What's a good API to do this? Just a global variable that sets the output stream?
No globals, I'm thinking of just having an io::IO argument to Pkg3.foo(...) functions, which defaults to STDOUT.
(If there is also STDERR output, hopefully that can be written in terms of the new Base logging API, @warn etcetera, which has its own mechanisms to intercept output.)
A pretty large amount of options and state need to be passed around between all of these functions and that will only grow as we add more functionality to the interface. We should probably bite the bullet and have an type that wraps all of the options which can also have input, output and error streams in it.
It seems a bit odd to have an IO argument to something like Pkg.add. It is a bit similar as the @test macros don't take an IO. Like the logging system where you configure the logger itseld, I feel this should be somehow be set to Pkg3 as a whole and not on individual functions.
Using the logging system for this does make sense.
Just need some docs now.
I understand that IO as the first argument would be odd. For Pkg.status, however, I feel like it is appropriate, since the command has no side effects, other than printing to IO.
This would allow the syntax sprint(Pkg.status). I would be happy to write this PR myself.
Can't you just write
sprint(io -> Pkg.status(io=io))
?
Thanks! I missed the io keyword argument. I now see why Pkg.status should not take an IO as a first argument.
Most helpful comment
Just need some docs now.