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

Method run

atomic-cli/src/commands/vault/show.rs:50–82  ·  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::VaultEntityNotFound {
58 kind: "vault entry",
59 id: self.path.clone(),
60 hint: None,
61 })?;
62 let revision_hash =
63 (self.json || self.revision.is_some()).then(|| vault_entry_revision_hash(&entry));
64 if let Some(actual) = revision_hash.as_deref() {
65 require_revision(&self.path, self.revision.as_deref(), actual)?;
66 }
67
68 if self.json {
69 let json = entry_json(
70 &self.path,
71 &entry,
72 revision_hash
73 .as_deref()
74 .expect("JSON output always computes a revision"),
75 );
76 println!("{}", serde_json::to_string_pretty(&json).unwrap());
77 } else {
78 print!("{}", String::from_utf8_lossy(&entry.content_bytes));
79 }
80
81 Ok(())
82 }
83}
84
85fn require_revision(path: &str, expected: Option<&str>, actual: &str) -> CliResult<()> {

Callers

nothing calls this directly

Calls 6

find_repository_rootFunction · 0.85
require_revisionFunction · 0.85
entry_jsonFunction · 0.85
vault_retrieveMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected