(tokens: &[String])
| 571 | } |
| 572 | |
| 573 | fn parse_step_options(tokens: &[String]) -> StepOptions { |
| 574 | let mut options = StepOptions::default(); |
| 575 | let mut index = 0; |
| 576 | while index < tokens.len() { |
| 577 | let token = &tokens[index]; |
| 578 | if let Some(stripped) = token.strip_prefix("--") { |
| 579 | if let Some((key, value)) = stripped.split_once('=') { |
| 580 | options.values.push((key.to_owned(), value.to_owned())); |
| 581 | } else if index + 1 < tokens.len() && !tokens[index + 1].starts_with("--") { |
| 582 | options |
| 583 | .values |
| 584 | .push((stripped.to_owned(), tokens[index + 1].clone())); |
| 585 | index += 1; |
| 586 | } else { |
| 587 | options.flags.push(stripped.to_owned()); |
| 588 | } |
| 589 | } else if let Some(stripped) = token.strip_prefix('-') { |
| 590 | if index + 1 < tokens.len() && !tokens[index + 1].starts_with('-') { |
| 591 | options |
| 592 | .values |
| 593 | .push((stripped.to_owned(), tokens[index + 1].clone())); |
| 594 | index += 1; |
| 595 | } |
| 596 | } |
| 597 | index += 1; |
| 598 | } |
| 599 | options |
| 600 | } |
| 601 | |
| 602 | fn required_f64(args: &StepOptions, key: &str) -> Result<f64, crate::error::AppError> { |
| 603 | args.value(key) |
no test coverage detected