refactor: CheckFreshness and DiffDiagram take &str instead of &Path
This commit is contained in:
@@ -46,10 +46,12 @@ pub fn run(args: Cli) -> Result<()> {
|
||||
let existing_path = args.output.as_ref().ok_or_else(|| {
|
||||
anyhow::anyhow!("--check requires --output to specify the file to check against")
|
||||
})?;
|
||||
let existing_content = std::fs::read_to_string(existing_path)
|
||||
.map_err(|e| anyhow::anyhow!("cannot read {existing_path}: {e}"))?;
|
||||
let up_to_date = CheckFreshness {
|
||||
graph: &graph,
|
||||
renderer: &*renderer,
|
||||
existing_path: std::path::Path::new(existing_path),
|
||||
existing_content: &existing_content,
|
||||
}
|
||||
.execute()?;
|
||||
if up_to_date {
|
||||
@@ -222,10 +224,12 @@ fn run_diff(args: &Cli, existing_path: &std::path::Path) -> Result<()> {
|
||||
let graph = build_graph(args, level)?;
|
||||
let renderer = create_renderer(&args.format, level, !args.no_weights)?;
|
||||
|
||||
let existing_content = std::fs::read_to_string(existing_path)
|
||||
.map_err(|e| anyhow::anyhow!("cannot read {}: {e}", existing_path.display()))?;
|
||||
let diff = DiffDiagram {
|
||||
graph: &graph,
|
||||
renderer: &*renderer,
|
||||
existing_path,
|
||||
existing_content: &existing_content,
|
||||
}
|
||||
.execute()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user