clean up
This commit is contained in:
@@ -56,7 +56,11 @@ where
|
||||
el
|
||||
})
|
||||
.collect();
|
||||
(elements, result.relationships().to_vec(), result.warnings().to_vec())
|
||||
(
|
||||
elements,
|
||||
result.relationships().to_vec(),
|
||||
result.warnings().to_vec(),
|
||||
)
|
||||
}
|
||||
Err(err) => {
|
||||
let mut warnings = Vec::new();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use archlens_domain::{
|
||||
BoundaryRule, DomainError, NormalizedGraph, RenderedFile, RenderOutput,
|
||||
check_boundary_rules,
|
||||
BoundaryRule, DomainError, NormalizedGraph, RenderOutput, RenderedFile, check_boundary_rules,
|
||||
ports::DiagramRenderer,
|
||||
};
|
||||
|
||||
@@ -72,9 +71,7 @@ pub fn write_split(
|
||||
output_dir: &Option<PathBuf>,
|
||||
ext: &str,
|
||||
) -> Result<(), DomainError> {
|
||||
let dir = output_dir
|
||||
.clone()
|
||||
.unwrap_or_else(|| PathBuf::from("."));
|
||||
let dir = output_dir.clone().unwrap_or_else(|| PathBuf::from("."));
|
||||
|
||||
let overview = renderer.render(graph.as_graph())?;
|
||||
let overview_file = RenderedFile::new(
|
||||
@@ -89,7 +86,11 @@ pub fn write_split(
|
||||
let module_output = renderer.render_for_module(&subgraph, &module, &cross_deps)?;
|
||||
let module_file = RenderedFile::new(
|
||||
&format!("{}.{ext}", module.as_str().to_lowercase()),
|
||||
module_output.files().first().map(|f| f.content()).unwrap_or(""),
|
||||
module_output
|
||||
.files()
|
||||
.first()
|
||||
.map(|f| f.content())
|
||||
.unwrap_or(""),
|
||||
)?;
|
||||
write_file_to_dir(&dir, module_file)?;
|
||||
}
|
||||
@@ -99,10 +100,8 @@ pub fn write_split(
|
||||
|
||||
fn write_file_to_dir(dir: &PathBuf, file: RenderedFile) -> Result<(), DomainError> {
|
||||
let path = dir.join(file.name());
|
||||
std::fs::create_dir_all(dir)
|
||||
.map_err(|e| DomainError::IoError(e.to_string()))?;
|
||||
std::fs::write(&path, file.content())
|
||||
.map_err(|e| DomainError::IoError(e.to_string()))?;
|
||||
std::fs::create_dir_all(dir).map_err(|e| DomainError::IoError(e.to_string()))?;
|
||||
std::fs::write(&path, file.content()).map_err(|e| DomainError::IoError(e.to_string()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -111,11 +110,9 @@ fn write_to_output(rendered: RenderOutput, output: &Option<PathBuf>) -> Result<(
|
||||
match output {
|
||||
Some(path) => {
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent)
|
||||
.map_err(|e| DomainError::IoError(e.to_string()))?;
|
||||
std::fs::create_dir_all(parent).map_err(|e| DomainError::IoError(e.to_string()))?;
|
||||
}
|
||||
std::fs::write(path, content)
|
||||
.map_err(|e| DomainError::IoError(e.to_string()))
|
||||
std::fs::write(path, content).map_err(|e| DomainError::IoError(e.to_string()))
|
||||
}
|
||||
None => {
|
||||
print!("{content}");
|
||||
|
||||
Reference in New Issue
Block a user