ink icon indicating copy to clipboard operation
ink copied to clipboard

How to pipe a subprocess' output?

Open cevr opened this issue 4 years ago • 6 comments

Hi! This project seems amazing.

I have a use case where I want to build a CLI on top of lerna, so ideally I would like to be able to set a Box where the output is whatever lerna spits out.

Is there a recipe to do this with Ink?

Thank you!

cevr avatar Jul 30 '20 17:07 cevr

I don't think you have to do anything special. Just save the stdout to an array or something & render it. The output from stdout I think can be treated as data like anything else.

mAAdhaTTah avatar Jul 30 '20 18:07 mAAdhaTTah

@mAAdhaTTah Thanks, I'll try that!

cevr avatar Jul 30 '20 18:07 cevr

@cevr would be cool to see the result when you got it :)

nitsanavni avatar Jul 31 '20 16:07 nitsanavni

@mAAdhaTTah is correct, as long as you get output text from the sub process, you can render it inside <Text>.

vadimdemedes avatar Jul 31 '20 19:07 vadimdemedes

@vadimdemedes What about preserving the output formating (like color)?

cevr avatar Jul 31 '20 20:07 cevr

I think it should work too.

vadimdemedes avatar Jul 31 '20 20:07 vadimdemedes