(&self)
| 48 | |
| 49 | impl 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 | |
| 85 | fn require_revision(path: &str, expected: Option<&str>, actual: &str) -> CliResult<()> { |
nothing calls this directly
no test coverage detected