(&mut self, flag: &str)
| 52 | } |
| 53 | |
| 54 | pub(crate) fn value_for(&mut self, flag: &str) -> Result<String, String> { |
| 55 | if let Some(value) = self.pending_value.take() { |
| 56 | if value.is_empty() { |
| 57 | return Err(format!("Missing value for {flag}")); |
| 58 | } |
| 59 | return Ok(value); |
| 60 | } |
| 61 | let value = self |
| 62 | .next() |
| 63 | .ok_or_else(|| format!("Missing value for {flag}"))?; |
| 64 | if value.starts_with('-') { |
| 65 | return Err(format!("Missing value for {flag}")); |
| 66 | } |
| 67 | Ok(value) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | #[cfg(test)] |
no test coverage detected