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

Method run

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

Source from the content-addressed store, hash-verified

47
48impl Command for Show {
49 fn run(&self) -> CliResult<()> {
50 // Every form routes: the wire resolves by path and carries the
51 // stored entry's full domain bytes, so the revision hash, the
52 // JSON projection, and the --revision guard all run client-side
53 // over wire-carried data.
54 if crate::commands::rpc::vault_show(self)? {
55 return Ok(());
56 }
57
58 let root = find_repository_root()?;
59 let repo =
60 crate::commands::open_readonly_repository(&root).map_err(CliError::Repository)?;
61
62 let entry = repo
63 .vault_retrieve(&self.path)
64 .map_err(CliError::Repository)?
65 .ok_or_else(|| CliError::VaultEntityNotFound {
66 kind: "vault entry",
67 id: self.path.clone(),
68 hint: None,
69 })?;
70 let revision_hash =
71 (self.json || self.revision.is_some()).then(|| vault_entry_revision_hash(&entry));
72 if let Some(actual) = revision_hash.as_deref() {
73 require_revision(&self.path, self.revision.as_deref(), actual)?;
74 }
75
76 if self.json {
77 let json = entry_json(
78 &self.path,
79 &entry,
80 revision_hash
81 .as_deref()
82 .expect("JSON output always computes a revision"),
83 );
84 println!("{}", serde_json::to_string_pretty(&json).unwrap());
85 } else {
86 print!("{}", String::from_utf8_lossy(&entry.content_bytes));
87 }
88
89 Ok(())
90 }
91}
92
93pub(crate) fn require_revision(path: &str, expected: Option<&str>, actual: &str) -> CliResult<()> {

Callers

nothing calls this directly

Calls 8

vault_showFunction · 0.85
find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 0.85
require_revisionFunction · 0.85
vault_retrieveMethod · 0.80
entry_jsonFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected