init: archlens — architecture diagram generator
Some checks failed
CI / Check / Test (push) Failing after 1m24s

Hex arch + DDD, tree-sitter parsing, Mermaid/ASCII output.
Supports Rust + Python. 92 tests. CI, diff, --check for staleness detection.
This commit is contained in:
2026-06-16 16:13:04 +02:00
commit 35f27d00b0
106 changed files with 6744 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
use std::fs;
use std::path::PathBuf;
use archlens_domain::{DomainError, RenderOutput, ports::OutputWriter};
pub struct FileOutputWriter {
output_path: OutputPath,
}
enum OutputPath {
Directory(PathBuf),
File(PathBuf),
}
impl FileOutputWriter {
pub fn new(output_dir: PathBuf) -> Self {
Self {
output_path: OutputPath::Directory(output_dir),
}
}
pub fn single_file(path: PathBuf) -> Self {
Self {
output_path: OutputPath::File(path),
}
}
}
impl OutputWriter for FileOutputWriter {
fn write(&self, output: &RenderOutput) -> Result<(), DomainError> {
match &self.output_path {
OutputPath::File(path) => {
if let Some(parent) = path.parent() {
fs::create_dir_all(parent).map_err(|e| DomainError::IoError(e.to_string()))?;
}
let content = output.files().first().map(|f| f.content()).unwrap_or("");
fs::write(path, content).map_err(|e| DomainError::IoError(e.to_string()))?;
}
OutputPath::Directory(dir) => {
fs::create_dir_all(dir).map_err(|e| DomainError::IoError(e.to_string()))?;
for file in output.files() {
let path = dir.join(file.name());
fs::write(&path, file.content())
.map_err(|e| DomainError::IoError(e.to_string()))?;
}
}
}
Ok(())
}
}

View File

@@ -0,0 +1,3 @@
mod file_output_writer;
pub use file_output_writer::FileOutputWriter;