#![cfg_attr(
    all(not(debug_assertions), target_os = "windows"),
    windows_subsystem = "windows"
)]

use creddy::{
    app,
    cli,
    errors::ShowError,
};


fn main() {
    let res = match cli::parser().get_matches().subcommand() {
        None | Some(("run", _)) => {
            app::run().error_popup("Creddy failed to start");
            Ok(())
        },
        Some(("get", m)) => cli::get(m),
        Some(("exec", m)) => cli::exec(m),
        Some(("shortcut", m)) => cli::invoke_shortcut(m),
        _ => unreachable!(),
    };

    if let Err(e) = res {
        eprintln!("Error: {e}");
        std::process::exit(1);
    }
}
