MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / vault_show

Function vault_show

atomic-cli/src/commands/rpc.rs:2091–2137  ·  view source on GitHub ↗

`atomic vault show ` over GetVaultEntry — every form. The wire resolves by vault-relative path (any entry type) and carries the stored entry's full domain bytes, so the revision hash, the JSON projection (entry type, frontmatter, created/updated dates), and the `--revision` guard all run client-side over wire-carried data with the SAME functions the local body uses.

(args: &super::vault::show::Show)

Source from the content-addressed store, hash-verified

2089/// `--revision` guard all run client-side over wire-carried data with
2090/// the SAME functions the local body uses.
2091pub fn vault_show(args: &super::vault::show::Show) -> CliResult<bool> {
2092 let Some(session) = Service::open()? else {
2093 return Ok(false);
2094 };
2095 // The raw argument names the entry exactly as the local body's
2096 // vault_retrieve does (vault-relative; a `.vault/`-prefixed path
2097 // fails the same lookup both ways).
2098 let path = args.path.clone();
2099 let request = pb::GetVaultEntryRequest {
2100 repository: Some(session.reference.clone()),
2101 kind: Kind::Unspecified as i32,
2102 id: String::new(),
2103 path: Some(path.clone()),
2104 include_bundle: true,
2105 view: None,
2106 };
2107 let response = session.get_vault_entry(request)?;
2108 let Some(bundle) = response
2109 .entry_bundle
2110 .as_ref()
2111 .map(parse_entry_bundle)
2112 .transpose()?
2113 else {
2114 return Err(CliError::Internal(anyhow::anyhow!(
2115 "the service returned no entry bundle (include_bundle required)"
2116 )));
2117 };
2118 let entry = &bundle.entry;
2119 let revision_hash = (args.json || args.revision.is_some())
2120 .then(|| super::vault::vault_entry_revision_hash(entry));
2121 if let Some(actual) = revision_hash.as_deref() {
2122 super::vault::show::require_revision(&path, args.revision.as_deref(), actual)?;
2123 }
2124 if args.json {
2125 let json = super::vault::show::entry_json(
2126 &path,
2127 entry,
2128 revision_hash
2129 .as_deref()
2130 .expect("JSON output always computes a revision"),
2131 );
2132 println!("{}", serde_json::to_string_pretty(&json).unwrap());
2133 } else {
2134 print!("{}", String::from_utf8_lossy(&entry.content_bytes));
2135 }
2136 Ok(true)
2137}
2138
2139// ---------------------------------------------------------------------------
2140// diff / change / session / view list / goals / neighbors

Callers 1

runMethod · 0.85

Calls 7

openFunction · 0.85
require_revisionFunction · 0.85
as_refMethod · 0.80
entry_jsonFunction · 0.50
cloneMethod · 0.45
get_vault_entryMethod · 0.45

Tested by

no test coverage detected