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

Function read_batch_steps

packages/server/src/main/batch.rs:40–68  ·  view source on GitHub ↗
(
    steps: Vec<String>,
    file: Option<PathBuf>,
    use_stdin: bool,
)

Source from the content-addressed store, hash-verified

38}
39
40fn read_batch_steps(
41 steps: Vec<String>,
42 file: Option<PathBuf>,
43 use_stdin: bool,
44) -> anyhow::Result<Vec<String>> {
45 let source_count =
46 usize::from(!steps.is_empty()) + usize::from(file.is_some()) + usize::from(use_stdin);
47 if source_count != 1 {
48 return Err(crate::error::AppError::bad_request(
49 "Specify exactly one batch source: --step, --file, or --stdin.",
50 )
51 .into());
52 }
53 let raw = if use_stdin {
54 let mut buffer = String::new();
55 io::stdin().read_to_string(&mut buffer)?;
56 buffer
57 } else if let Some(file) = file {
58 fs::read_to_string(file)?
59 } else {
60 return Ok(steps);
61 };
62 Ok(raw
63 .lines()
64 .map(str::trim)
65 .filter(|line| !line.is_empty() && !line.starts_with('#'))
66 .map(str::to_owned)
67 .collect())
68}
69
70fn batch_lines_to_json_steps(step_lines: &[String]) -> anyhow::Result<Vec<Value>> {
71 step_lines

Callers 2

mainFunction · 0.85
run_batchFunction · 0.85

Calls 1

is_emptyMethod · 0.80

Tested by

no test coverage detected