Returns the parsed key and value from option of the form `--key=value`, `-c key=value`, or `-ckey=value`. Keys replace `-` with `_`. Returns an error if there was some other prefix.
(option: &str)
| 678 | /// key=value`, or `-ckey=value`. Keys replace `-` with `_`. Returns an error if |
| 679 | /// there was some other prefix. |
| 680 | fn parse_option(option: &str) -> Result<(&str, &str), ()> { |
| 681 | let (key, value) = option.split_once('=').ok_or(())?; |
| 682 | for prefix in &["-c", "--"] { |
| 683 | if let Some(key) = key.strip_prefix(prefix) { |
| 684 | return Ok((key, value)); |
| 685 | } |
| 686 | } |
| 687 | Err(()) |
| 688 | } |
| 689 | |
| 690 | /// Splits value by any number of spaces except those preceded by `\`. |
| 691 | fn split_options(value: &str) -> Vec<String> { |
no outgoing calls