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

Method run

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

Source from the content-addressed store, hash-verified

48
49impl Command for Show {
50 fn run(&self) -> CliResult<()> {
51 let root = find_repository_root()?;
52 let repo = Repository::open_readonly(&root).map_err(CliError::Repository)?;
53
54 let entry = repo
55 .vault_retrieve(&self.path)
56 .map_err(CliError::Repository)?
57 .ok_or_else(|| CliError::InvalidArgument {
58 message: format!("Vault entry not found: {}", self.path),
59 })?;
60 let revision_hash =
61 (self.json || self.revision.is_some()).then(|| vault_entry_revision_hash(&entry));
62 if let Some(actual) = revision_hash.as_deref() {
63 require_revision(&self.path, self.revision.as_deref(), actual)?;
64 }
65
66 if self.json {
67 let json = entry_json(
68 &self.path,
69 &entry,
70 revision_hash
71 .as_deref()
72 .expect("JSON output always computes a revision"),
73 );
74 println!("{}", serde_json::to_string_pretty(&json).unwrap());
75 } else {
76 print!("{}", String::from_utf8_lossy(&entry.content_bytes));
77 }
78
79 Ok(())
80 }
81}
82
83fn require_revision(path: &str, expected: Option<&str>, actual: &str) -> CliResult<()> {

Callers

nothing calls this directly

Calls 5

find_repository_rootFunction · 0.85
require_revisionFunction · 0.85
entry_jsonFunction · 0.85
vault_retrieveMethod · 0.80

Tested by

no test coverage detected