I know how to read the command line arguments, but I am having difficulties reading the command output from a pipe.
Connect a program (A) that outputs data to my Rust program using a pipe:
A | R
The program should consume the data line by line as they come.
$ pwd | cargo run
should print thepwd
output.OR
$ find . | cargo run
should output thefind
command output which is more than 1 line.
lock()
, this will break the purpose of a pipe,find
will write its output in a stream, but you are currently lock and read only what find has already read. Awhile
loop withread_line()
will not be more idiomatic and functional ? – There