(&self)
| 37 | |
| 38 | impl Command for MemoryWrite { |
| 39 | fn run(&self) -> CliResult<()> { |
| 40 | let root = find_repository_root()?; |
| 41 | let repo = Repository::open(&root).map_err(CliError::Repository)?; |
| 42 | |
| 43 | // Freeform body from stdin — no lift/gate; this is the raw path. |
| 44 | use std::io::Read; |
| 45 | let mut content = String::new(); |
| 46 | std::io::stdin() |
| 47 | .read_to_string(&mut content) |
| 48 | .map_err(CliError::Io)?; |
| 49 | |
| 50 | let path = bridge::normalize_memory_path(&self.name); |
| 51 | let frontmatter = serde_json::json!({ |
| 52 | "name": self.name.replace(".md", ""), |
| 53 | "type": self.r#type, |
| 54 | }) |
| 55 | .to_string(); |
| 56 | |
| 57 | let hash = repo |
| 58 | .vault_store( |
| 59 | &path, |
| 60 | VaultEntryType::Memory, |
| 61 | content.into_bytes(), |
| 62 | frontmatter, |
| 63 | ) |
| 64 | .map_err(CliError::Repository)?; |
| 65 | repo.vault_materialize(&path) |
| 66 | .map_err(CliError::Repository)?; |
| 67 | |
| 68 | println!("Wrote memory: {} ({})", path, &hash.to_string()[..12]); |
| 69 | Ok(()) |
| 70 | } |
| 71 | } |
nothing calls this directly
no test coverage detected