use std::io;
use clap::Parser;
use repograph_core::RepographError;
use crate::{output, selfupdate};
#[derive(Debug, Parser)]
pub struct Args {
#[arg(long)]
pub check: bool,
}
#[tracing::instrument(skip(args), fields(check = args.check))]
pub fn run(args: &Args) -> Result<(), RepographError> {
tracing::debug!(command = "update", check = args.check, "start");
let outcome = selfupdate::run_update(args.check)?;
let mut stderr = io::stderr().lock();
output::render_update_outcome(&mut stderr, &outcome)?;
tracing::info!(outcome = ?outcome, "update finished");
Ok(())
}