MCPcopy Index your code
hub / github.com/arraypad/each / process

Function process

src/main.rs:271–300  ·  view source on GitHub ↗
(values: &[serde_json::Value], action: &Action)

Source from the content-addressed store, hash-verified

269}
270
271fn process(values: &[serde_json::Value], action: &Action) -> Result<(), EachError> {
272 let results: Result<Vec<()>, EachError> = values
273 .par_iter()
274 .map(|value| -> Result<(), EachError> {
275 let cmd = action.prepare(value).map_err(|e| EachError::Data {
276 message: format!("failed to prepare command: {:?}", e),
277 })?;
278
279 let run = if action.prompt {
280 let prompt = action.prompt(&cmd, value).map_err(|e| EachError::Data {
281 message: format!("failed to render stdin: {:?}", e),
282 })?;
283
284 Confirm::new().with_prompt(&prompt).interact()?
285 } else {
286 true
287 };
288
289 if run {
290 action.run(cmd).map_err(|e| EachError::Data {
291 message: format!("failed to run command: {:?}", e),
292 })?;
293 }
294
295 Ok(())
296 })
297 .collect();
298
299 results.map(|_| ())
300}

Callers 1

runFunction · 0.85

Calls 3

prepareMethod · 0.80
promptMethod · 0.80
runMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…