MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_option

Function parse_option

src/pgwire/src/protocol.rs:680–688  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

678/// key=value`, or `-ckey=value`. Keys replace `-` with `_`. Returns an error if
679/// there was some other prefix.
680fn 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 `\`.
691fn split_options(value: &str) -> Vec<String> {

Callers 2

parse_optionsFunction · 0.85
test_parse_optionFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_parse_optionFunction · 0.68