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

Method run

atomic-cli/src/commands/vault/show.rs:37–65  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

35
36impl Command for Show {
37 fn run(&self) -> CliResult<()> {
38 let root = find_repository_root()?;
39 let repo = Repository::open(&root).map_err(CliError::Repository)?;
40
41 let entry = repo
42 .vault_retrieve(&self.path)
43 .map_err(CliError::Repository)?
44 .ok_or_else(|| CliError::InvalidArgument {
45 message: format!("Vault entry not found: {}", self.path),
46 })?;
47
48 if self.json {
49 let json = serde_json::json!({
50 "path": self.path,
51 "entry_type": entry.entry_type.to_string(),
52 "content": String::from_utf8_lossy(&entry.content_bytes),
53 "frontmatter": serde_json::from_str::<serde_json::Value>(
54 &entry.frontmatter_json
55 ).unwrap_or_default(),
56 "created_at": entry.created_at,
57 "updated_at": entry.updated_at,
58 });
59 println!("{}", serde_json::to_string_pretty(&json).unwrap());
60 } else {
61 print!("{}", String::from_utf8_lossy(&entry.content_bytes));
62 }
63
64 Ok(())
65 }
66}

Callers

nothing calls this directly

Calls 2

find_repository_rootFunction · 0.85
vault_retrieveMethod · 0.80

Tested by

no test coverage detected