1use crate::protocol::{Request, Response};
2
3pub async fn execute(
4 session: &str,
5 target: &str,
6 until: Option<String>,
7 regex: bool,
8 exit: bool,
9 timeout: Option<u64>,
10) -> i32 {
11 let req = Request::Wait {
12 target: target.into(),
13 until,
14 regex,
15 exit,
16 timeout_secs: timeout,
17 };
18 crate::cli::request_and_handle(session, &req, false, |resp| match resp {
19 Response::WaitMatch { line } => {
20 println!("{}", line);
21 Some(0)
22 }
23 Response::WaitExited { exit_code } => {
24 match exit_code {
25 Some(code) => println!("exited with code {}", code),
26 None => println!("exited by signal"),
27 }
28 Some(0)
29 }
30 Response::WaitTimeout => {
31 eprintln!("timeout");
32 Some(1)
33 }
34 _ => None,
35 })
36 .await
37}