| 3355 | } |
| 3356 | |
| 3357 | fn parse_optional_udid_text_args( |
| 3358 | command: &str, |
| 3359 | args: Vec<String>, |
| 3360 | has_non_positional_input: bool, |
| 3361 | ) -> anyhow::Result<(Option<String>, Option<String>)> { |
| 3362 | let args = clean_cli_args(args); |
| 3363 | if has_non_positional_input { |
| 3364 | return match args.as_slice() { |
| 3365 | [] => Ok((None, None)), |
| 3366 | [udid] => Ok((Some(udid.clone()), None)), |
| 3367 | _ => anyhow::bail!( |
| 3368 | "{command} accepts at most one positional UDID with --stdin or --file." |
| 3369 | ), |
| 3370 | }; |
| 3371 | } |
| 3372 | match args.as_slice() { |
| 3373 | [] => Ok((None, None)), |
| 3374 | [text] => Ok((None, Some(text.clone()))), |
| 3375 | [udid, text] => Ok((Some(udid.clone()), Some(text.clone()))), |
| 3376 | _ => anyhow::bail!("{command} accepts either TEXT or UDID TEXT. Quote multi-word text."), |
| 3377 | } |
| 3378 | } |
| 3379 | |
| 3380 | fn parse_optional_udid_f64_args( |
| 3381 | command: &str, |