//! Command-line entry point for the terminal application.

use std::process::ExitCode;

fn main() -> ExitCode {
    let args: Vec<String> = std::env::args().collect();
    let result = match args.get(1).map(String::as_str) {
        None => rsstacker::tui::run(),
        Some("replay") => match args.get(2) {
            Some(path) => rsstacker::tui::run_replay(path),
            None => {
                eprintln!("usage: rsstacker replay <file.recording>");
                return ExitCode::from(2);
            }
        },
        _ => {
            eprintln!("usage: rsstacker [replay <file.recording>]");
            return ExitCode::from(2);
        }
    };
    if let Err(e) = result {
        eprintln!("error: {e}");
        return ExitCode::from(1);
    }
    ExitCode::SUCCESS
}
