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