(maybe_config: Result<Config, AppError>, cmd: &str, tags: &BTreeSet<String>, parallel_raw: &Option<String>)
| 105 | } |
| 106 | |
| 107 | pub fn foreach(maybe_config: Result<Config, AppError>, cmd: &str, tags: &BTreeSet<String>, parallel_raw: &Option<String>) -> Result<(), AppError> { |
| 108 | let config = maybe_config?; |
| 109 | init_threads(parallel_raw)?; |
| 110 | |
| 111 | let projects: Vec<&Project> = config.projects.values().collect(); |
| 112 | let script_results = projects |
| 113 | .par_iter() |
| 114 | .filter(|p| tags.is_empty() || p.tags.clone().unwrap_or_default().intersection(tags).count() > 0) |
| 115 | .map(|p| { |
| 116 | let shell = config.settings.get_shell_or_default(); |
| 117 | let path = config.actual_path_to_project(p); |
| 118 | spawn_maybe(&shell, cmd, &path, &p.name, random_color()) |
| 119 | }) |
| 120 | .collect::<Vec<Result<(), AppError>>>(); |
| 121 | |
| 122 | script_results.into_iter().fold(Ok(()), Result::and) |
| 123 | } |
no test coverage detected