MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / parse_port

Function parse_port

nodedb/src/ctl/healthcheck.rs:73–81  ·  view source on GitHub ↗

Parse `--port N` (optional, defaults to [`DEFAULT_PORT`]).

(args: &[String])

Source from the content-addressed store, hash-verified

71
72/// Parse `--port N` (optional, defaults to [`DEFAULT_PORT`]).
73pub 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)]
84mod tests {

Callers 1

parse_subcommandFunction · 0.85

Calls 3

parse_flagsFunction · 0.85
to_stringMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected