Closed jakeheis closed 6 years ago
Yes that would be useful. But AsyncCommand.init is not public, so we need to change the public api. Do you think the use case is common enough to warrant a new function runAsyncAndPrint
, which returns a superclass of AsyncCommand without stdout
and stderror
?
Usually one use case is enough to constantly bite you in the ass i always say 😄. I like this library. I vote yes.
I’m about to do some refactoring of Command.swift
to move anything Linux-specific to its own file. I will implement runAsyncAndPrint
after that.
Does anyone have a better idea for the name? It is a bit wordy, but I think it fits in nicely with run, runAsync and runAndPrint.
Ideally this functionality should be implemented with an extra parameter on runAsync, but the return type needs to be different.
@jakeheis I implemented runAsyncAndPrint in branch 61-AsyncCommand_use_main.stdout.
will take pull.
Just released version 4.1 with this feature.
Right now,
AsyncCommand
will always change the process's stdout and stderr to aPipe
(https://github.com/kareman/SwiftShell/blob/master/Sources/SwiftShell/Command.swift#L291).There should be a way to start an
AsyncCommand
which still directs output tomain.stdout
andmain.stderr
. Simply forwarding the output using something like:is not sufficient, as pipes are block buffered but
main.stdout
is line buffered, so the command's output will not be written to stdout in the expected way.I think this could potentially be solved by changing
AsyncCommand.init
to something like: