use crate::console::attach_ctrl_c_handler;
use crate::console::console_detach;
use crate::console::is_inheriting_console;

pub fn hide_default_console_or_attach_ctrl_handler() -> eyre::Result<()> {
    if is_inheriting_console() {
        // There is an existing console (e.g., VSCode), so attach ctrl+c handler for graceful shutdowns
        attach_ctrl_c_handler()?;
    } else {
        // No existing console (e.g., double-clicked exe), so detach from the default console window
        // No need for ctrl+c handler since there is no console to send ctrl+c to
        _ = console_detach();
    };

    Ok(())
}
