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

Function vault_show

atomic-cli/src/commands/rpc.rs:2092–2138  ·  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

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

Callers 1

runMethod · 0.85

Calls 7

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

Tested by

no test coverage detected