MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / run_batch

Function run_batch

packages/server/src/main/batch.rs:1–38  ·  view source on GitHub ↗
(
    bridge: &NativeBridge,
    udid: &str,
    steps: Vec<String>,
    file: Option<PathBuf>,
    use_stdin: bool,
    continue_on_error: bool,
)

Source from the content-addressed store, hash-verified

1fn run_batch(
2 bridge: &NativeBridge,
3 udid: &str,
4 steps: Vec<String>,
5 file: Option<PathBuf>,
6 use_stdin: bool,
7 continue_on_error: bool,
8) -> anyhow::Result<Value> {
9 let step_lines = read_batch_steps(steps, file, use_stdin)?;
10 let mut results = Vec::new();
11 let mut failures = Vec::new();
12 for (index, line) in step_lines.iter().enumerate() {
13 let result = run_batch_step(bridge, udid, line);
14 match result {
15 Ok(action) => {
16 results.push(serde_json::json!({ "index": index, "ok": true, "action": action }))
17 }
18 Err(error) => {
19 let message = error.to_string();
20 results.push(serde_json::json!({ "index": index, "ok": false, "error": message }));
21 failures.push(message);
22 if !continue_on_error {
23 return Err(crate::error::AppError::bad_request(format!(
24 "Batch step {} failed: {}",
25 index + 1,
26 failures.last().unwrap()
27 ))
28 .into());
29 }
30 }
31 }
32 }
33 Ok(serde_json::json!({
34 "ok": failures.is_empty(),
35 "steps": results,
36 "failureCount": failures.len()
37 }))
38}
39
40fn read_batch_steps(
41 steps: Vec<String>,

Callers 1

mainFunction · 0.85

Calls 2

read_batch_stepsFunction · 0.85
run_batch_stepFunction · 0.70

Tested by

no test coverage detected