(command: &Option<Command>, config: &Config, cli: &Cli)
| 27 | } |
| 28 | |
| 29 | pub(crate) async fn handle(command: &Option<Command>, config: &Config, cli: &Cli) { |
| 30 | match command { |
| 31 | Some(Command::Add { file }) => connect(config, cli) |
| 32 | .await |
| 33 | .pipe_borrow(|client| { |
| 34 | load_files::<DockerHost>(file, cli).then(|values| { |
| 35 | join_all( |
| 36 | values |
| 37 | .iter() |
| 38 | .map(|value| client.add_docker_host(value.clone())), |
| 39 | ) |
| 40 | }) |
| 41 | }) |
| 42 | .await |
| 43 | .into_iter() |
| 44 | .collect::<Result<Vec<_>>>() |
| 45 | .map(|result| result.into_iter().collect_or_unwrap()) |
| 46 | .print_result(cli), |
| 47 | |
| 48 | Some(Command::Edit { file }) => connect(config, cli) |
| 49 | .await |
| 50 | .pipe_borrow(|client| { |
| 51 | load_files(file, cli).then(|values| { |
| 52 | join_all( |
| 53 | values |
| 54 | .into_iter() |
| 55 | .map(|value| client.edit_docker_host(value)), |
| 56 | ) |
| 57 | }) |
| 58 | }) |
| 59 | .await |
| 60 | .into_iter() |
| 61 | .collect::<Result<Vec<_>>>() |
| 62 | .map(|result| result.into_iter().collect_or_unwrap()) |
| 63 | .print_result(cli), |
| 64 | |
| 65 | Some(Command::Get { id }) => connect(config, cli) |
| 66 | .await |
| 67 | .pipe_borrow(|client| join_all(id.iter().map(|id| client.get_docker_host(*id)))) |
| 68 | .await |
| 69 | .into_iter() |
| 70 | .collect::<Result<Vec<_>>>() |
| 71 | .map(|result| result.into_iter().collect_or_unwrap()) |
| 72 | .print_result(cli), |
| 73 | |
| 74 | Some(Command::Delete { id }) => connect(config, cli) |
| 75 | .await |
| 76 | .pipe_borrow(|client| join_all(id.iter().map(|id| client.delete_docker_host(*id)))) |
| 77 | .await |
| 78 | .into_iter() |
| 79 | .collect::<Result<Vec<_>>>() |
| 80 | .map(|result| result.into_iter().collect_or_unwrap()) |
| 81 | .print_result(cli), |
| 82 | |
| 83 | Some(Command::List {}) => connect(config, cli) |
| 84 | .await |
| 85 | .get_docker_hosts() |
| 86 | .await |
nothing calls this directly
no test coverage detected