MCPcopy Create free account
hub / github.com/brocode/fw / foreach

Function foreach

src/spawn/mod.rs:107–123  ·  view source on GitHub ↗
(maybe_config: Result<Config, AppError>, cmd: &str, tags: &BTreeSet<String>, parallel_raw: &Option<String>)

Source from the content-addressed store, hash-verified

105}
106
107pub 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}

Callers 1

_mainFunction · 0.85

Calls 5

init_threadsFunction · 0.85
spawn_maybeFunction · 0.85
random_colorFunction · 0.85
get_shell_or_defaultMethod · 0.80

Tested by

no test coverage detected