Skip to main content

the_code_graph_cli/commands/
diff.rs

1use domain::error::Result;
2use domain::ports::GitProvider;
3use domain::use_cases::impact::ImpactUseCase;
4
5use crate::adapters::git::ShellGitProvider;
6use crate::commands::helpers::{open_graph, parse_confidence};
7use crate::commands::DiffArgs;
8use crate::output::{print, OutputFormat};
9
10pub fn run_diff(args: &DiffArgs, output_format: OutputFormat) -> Result<()> {
11    let (store, root) = open_graph()?;
12    let git = ShellGitProvider::new(root);
13    let hunks = git.diff_hunks(&args.from, args.to.as_deref())?;
14    let confidence = parse_confidence(&args.confidence)?;
15    let uc = ImpactUseCase::new(store);
16    let report = uc.diff_impact(&hunks, args.depth, confidence)?;
17    print(&report, output_format);
18    Ok(())
19}