amphp/parallel

Forwarding User Interaction and Feedback in CLI app

jenky opened this issue · 2 comments

Hi there! It's not an issue but rather a question.

I'm working on a CLI app that runs several tasks, and a few of them require user interaction (using Symfony IO or Laravel Prompt) during execution. How can I forward the input from the child process to the main stdout and receive feedback in the child processes? Thanks

Hi @jenky!

ProcessContext has getStdin() and getStdout() methods to return writable and readable streams, respectively, which may be used to read from STDOUT and write to STDIN of the child from within the parent process. In the parent, you can write the data read from the child STDOUT to STDOUT of the parent and take data received on STDIN of the parent and write it to STDIN of the child.