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

Function parse_optional_udid_f64_args

packages/server/src/main.rs:3380–3400  ·  view source on GitHub ↗
(
    command: &str,
    args: Vec<String>,
    expected_values: usize,
)

Source from the content-addressed store, hash-verified

3378}
3379
3380fn parse_optional_udid_f64_args(
3381 command: &str,
3382 args: Vec<String>,
3383 expected_values: usize,
3384) -> anyhow::Result<(Option<String>, Vec<f64>)> {
3385 let args = clean_cli_args(args);
3386 let (udid, values) = match args.len() {
3387 len if len == expected_values => (None, args.as_slice()),
3388 len if len == expected_values + 1 => (Some(args[0].clone()), &args[1..]),
3389 _ => anyhow::bail!(
3390 "{command} accepts either {expected_values} numeric values or UDID plus {expected_values} numeric values."
3391 ),
3392 };
3393 let mut parsed = Vec::with_capacity(values.len());
3394 for value in values {
3395 parsed.push(parse_f64_arg(value).ok_or_else(|| {
3396 anyhow::anyhow!("{command} expected a finite number, got {value:?}.")
3397 })?);
3398 }
3399 Ok((udid, parsed))
3400}
3401
3402fn parse_optional_udid_point_args(
3403 command: &str,

Calls 3

clean_cli_argsFunction · 0.85
parse_f64_argFunction · 0.85
cloneMethod · 0.65