(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) |
| 32 | .then(|values| join_all(values.into_iter().map(|value| client.add_tag(value)))) |
| 33 | }) |
| 34 | .await |
| 35 | .into_iter() |
| 36 | .collect::<Result<Vec<_>>>() |
| 37 | .map(|result| result.into_iter().collect_or_unwrap()) |
| 38 | .print_result(cli), |
| 39 | |
| 40 | Some(Command::Edit { file }) => connect(config, cli) |
| 41 | .await |
| 42 | .pipe_borrow(|client| { |
| 43 | load_files(file, cli) |
| 44 | .then(|values| join_all(values.into_iter().map(|value| client.edit_tag(value)))) |
| 45 | }) |
| 46 | .await |
| 47 | .into_iter() |
| 48 | .collect::<Result<Vec<_>>>() |
| 49 | .map(|result| result.into_iter().collect_or_unwrap()) |
| 50 | .print_result(cli), |
| 51 | |
| 52 | Some(Command::Get { id }) => connect(config, cli) |
| 53 | .await |
| 54 | .pipe_borrow(|client| join_all(id.iter().map(|id| client.get_tag(*id)))) |
| 55 | .await |
| 56 | .into_iter() |
| 57 | .collect::<Result<Vec<_>>>() |
| 58 | .map(|result| result.into_iter().collect_or_unwrap()) |
| 59 | .print_result(cli), |
| 60 | |
| 61 | Some(Command::Delete { id }) => connect(config, cli) |
| 62 | .await |
| 63 | .pipe_borrow(|client| join_all(id.iter().map(|id| client.delete_tag(*id)))) |
| 64 | .await |
| 65 | .into_iter() |
| 66 | .collect::<Result<Vec<_>>>() |
| 67 | .map(|result| result.into_iter().collect_or_unwrap()) |
| 68 | .print_result(cli), |
| 69 | |
| 70 | Some(Command::List {}) => connect(config, cli) |
| 71 | .await |
| 72 | .get_tags() |
| 73 | .await |
| 74 | .print_result(cli), |
| 75 | |
| 76 | None => {} |
| 77 | } |
| 78 | } |
no test coverage detected