Hi,
I wrote a tiny wrapper around docker compose commands. It works perfectly, however once in a while one of the commands also asks for user input with a "[y/N]" question and currently this is causing my cli tool to hang without forwarding the question back to me.
This is the command code:
fn exec_command(cmd: &str, args: Vec<&str>) -> bool {
let mut cli_command = Command::new(cmd)
.args(&args)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.unwrap();
for line_result in BufReader::new(cli_command.stdout.as_mut().unwrap()).lines() {
match line_result {
Ok(line) => {
print!("{}", line);
print!("\r\n");
}
Err(err) => {
eprintln!("{}", err);
}
}
}
for line_result in BufReader::new(cli_command.stderr.as_mut().unwrap()).lines() {
match line_result {
Ok(line) => {
print!("{}", line);
print!("\r\n");
}
Err(err) => {
eprintln!("{}", err);
}
}
}
cli_command.wait().unwrap().success()
}
I tried to add .stdin(Stdio:Piped())
but that didn't help.
How do I catch those requests for user input and forward them to the user?