mod app;
mod smartcast;

fn main()
{
	tracing_subscriber::fmt().with_target( false ).init();
	tracing::info!( "Eydos SmartCast starting..." );

	let force_light = std::env::args().any( |a| a == "--light" );
	let force_dark  = std::env::args().any( |a| a == "--dark" );

	use chrono::Timelike as _;
	let hour = chrono::Local::now().hour();
	let mode = if force_dark
	{
		ltk::ThemeMode::Dark
	} else if force_light {
		ltk::ThemeMode::Light
	} else if ( 6..18 ).contains( &hour ) {
		ltk::ThemeMode::Light
	} else {
		ltk::ThemeMode::Dark
	};

	if let Err( e ) = ltk::set_default_theme( mode )
	{
		tracing::error!( "smartcast: default theme not loadable ({e}). Install ltk-theme-default or set LTK_THEMES_DIR." );
		std::process::exit( 1 );
	}

	ltk::run( app::SmartcastApp::new() );
}
