use std::path::Path;
use weave_cli::gitscan;
type R<T> = Result<T, Box<dyn std::error::Error>>;
pub(crate) fn run(file: &str, json: bool, host: &weave_core::host::Host) -> R<()> {
let dir = Path::new(".");
let (base, ours, theirs) = gitscan::file_stages(dir, file)?;
let doc = weave_core::explain::explain(&base, &ours, &theirs, file, host);
if json {
println!("{}", serde_json::to_string_pretty(&doc)?);
} else {
print!("{}", doc.render());
if !doc.conflicts.is_empty() {
println!(
"\nrun `weave check` after you edit to verify the resolution against these \
three stages."
);
}
}
Ok(())
}