git-file-history 0.1.0

TUI for browsing the Git history of a single file
mod app;
mod cli;
mod error;
mod git;
mod startup;
mod terminal;
mod ui;

use std::env;

use cli::{parse_args, CliAction, USAGE};
use error::Result;
use terminal::escape_text;

fn main() {
    if let Err(err) = run() {
        for line in err.to_string().lines() {
            eprintln!("{}", escape_text(line));
        }
        std::process::exit(1);
    }
}

fn run() -> Result<()> {
    let file_path = match parse_args(env::args_os())? {
        CliAction::Run(file_path) => file_path,
        CliAction::Help => {
            println!("{USAGE}");
            return Ok(());
        }
        CliAction::Version => {
            println!("git-file-history {}", env!("CARGO_PKG_VERSION"));
            return Ok(());
        }
    };
    let app = startup::load_app(&file_path)?;

    terminal::run(app)
}