MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / load_profile_import_item

Function load_profile_import_item

crates/openshell-cli/src/run.rs:5498–5524  ·  view source on GitHub ↗
(
    path: &Path,
)

Source from the content-addressed store, hash-verified

5496}
5497
5498fn load_profile_import_item(
5499 path: &Path,
5500) -> Result<ProviderProfileImportItem, ProviderProfileDiagnostic> {
5501 let source = path.display().to_string();
5502 let input = std::fs::read_to_string(path).map_err(|err| {
5503 profile_file_diagnostic(
5504 &source,
5505 format!("failed to read provider profile file: {err}"),
5506 )
5507 })?;
5508 let profile = match path.extension().and_then(|ext| ext.to_str()) {
5509 Some("yaml" | "yml") => parse_profile_yaml(&input),
5510 Some("json") => parse_profile_json(&input),
5511 _ => {
5512 return Err(profile_file_diagnostic(
5513 &source,
5514 "unsupported provider profile file format".to_string(),
5515 ));
5516 }
5517 }
5518 .map_err(|err| profile_file_diagnostic(&source, err.to_string()))?;
5519
5520 Ok(ProviderProfileImportItem {
5521 profile: Some(profile.to_proto()),
5522 source,
5523 })
5524}
5525
5526fn profile_file_diagnostic(source: &str, message: String) -> ProviderProfileDiagnostic {
5527 ProviderProfileDiagnostic {

Callers 1

Calls 4

profile_file_diagnosticFunction · 0.85
parse_profile_yamlFunction · 0.85
parse_profile_jsonFunction · 0.85
to_protoMethod · 0.80

Tested by

no test coverage detected