main.rs (1097B)
1 mod api; 2 mod config; 3 mod display; 4 mod error; 5 mod league; 6 mod models; 7 8 use config::Cli; 9 use error::Result; 10 use league::League; 11 12 #[tokio::main] 13 async fn main() -> Result<()> { 14 let cli = Cli::parse_cli(); 15 let config = config::Config::from_cli(&cli)?; 16 let api_client = api::ApiClient::new(config.api_token); 17 18 if config.show_standings { 19 let league = config.league.unwrap_or(League::PremierLeague); 20 let standings = api_client.fetch_standings(league).await?; 21 display::display_standings(standings); 22 } else if let (false, Some(league)) = (config.show_all, config.league) { 23 let response = api_client.fetch_matches(league).await?; 24 let filtered = 25 display::filter_matches(response.matches, config.team_filter.as_deref(), false); 26 display::display_table(&filtered, false); 27 } else { 28 let response = api_client.fetch_all_matches().await?; 29 let filtered = 30 display::filter_matches(response.matches, config.team_filter.as_deref(), true); 31 display::display_table(&filtered, true); 32 } 33 34 Ok(()) 35 }