use anyhow::{Context, Result};
use owo_colors::OwoColorize;
use std::path::Path;
use kx_fides_core::hash::hash_file;
use super::HashArgs;
pub fn run(args: HashArgs) -> Result<()> {
let media = args.media;
let display = media.display();
if !Path::new(&media).exists() {
anyhow::bail!("media file not found: {}", display);
}
let h = hash_file(&media).with_context(|| format!("failed to hash {}", display))?;
println!(
"{} {}",
"✓ hashed".green().bold(),
display
);
println!("{} {}", "algorithm:".cyan(), h.algorithm);
println!("{} {}", "size:".cyan(), h.size);
println!("{} {}", "hash:".cyan(), h.value);
Ok(())
}