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

Method parse_ref

src/ore/src/url.rs:84–111  ·  view source on GitHub ↗
(
        &self,
        cmd: &clap::Command,
        arg: Option<&clap::Arg>,
        value: &std::ffi::OsStr,
    )

Source from the content-addressed store, hash-verified

82 type Value = SensitiveUrl;
83
84 fn parse_ref(
85 &self,
86 cmd: &clap::Command,
87 arg: Option<&clap::Arg>,
88 value: &std::ffi::OsStr,
89 ) -> Result<Self::Value, clap::Error> {
90 let s = value
91 .to_str()
92 .ok_or_else(|| clap::Error::new(clap::error::ErrorKind::InvalidUtf8).with_cmd(cmd))?;
93 let url = s.parse().map_err(|_e| {
94 let mut err = clap::Error::new(clap::error::ErrorKind::ValueValidation);
95 if let Some(arg) = arg {
96 err.insert(
97 clap::error::ContextKind::InvalidArg,
98 clap::error::ContextValue::String(arg.to_string()),
99 );
100 }
101 err.insert(
102 clap::error::ContextKind::InvalidValue,
103 clap::error::ContextValue::String("<redacted>".to_string()),
104 );
105 // TODO: waiting on https://github.com/clap-rs/clap/issues/5065
106 // to be resolved
107 // err.set_source(e);
108 err
109 })?;
110 Ok(SensitiveUrl(url))
111 }
112}
113
114#[cfg(feature = "cli")]

Callers

nothing calls this directly

Calls 6

StringClass · 0.85
SensitiveUrlClass · 0.85
to_strMethod · 0.80
parseMethod · 0.45
insertMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected