Parse `--port N` (optional, defaults to [`DEFAULT_PORT`]).
(args: &[String])
| 71 | |
| 72 | /// Parse `--port N` (optional, defaults to [`DEFAULT_PORT`]). |
| 73 | pub fn parse_port(args: &[String]) -> Result<u16, String> { |
| 74 | let flags = super::args::parse_flags(args)?; |
| 75 | match flags.get("port") { |
| 76 | Some(s) => s |
| 77 | .parse::<u16>() |
| 78 | .map_err(|_| "--port must be a u16".to_string()), |
| 79 | None => Ok(DEFAULT_PORT), |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | #[cfg(test)] |
| 84 | mod tests { |
no test coverage detected