feat: Initial working prototype
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -3,29 +3,22 @@ use api::{JellyfinClient, JellyfinConfig};
|
||||
use errors::*;
|
||||
|
||||
fn jellyfin_config_try() -> Result<JellyfinConfig> {
|
||||
dotenvy::dotenv()
|
||||
let file = std::fs::read("config.toml").change_context(Error)?;
|
||||
let config: JellyfinConfig = toml::from_slice(&file)
|
||||
.change_context(Error)
|
||||
.inspect_err(|err| {
|
||||
eprintln!("Failed to load .env file: {}", err);
|
||||
})
|
||||
.ok();
|
||||
let config = JellyfinConfig::new(
|
||||
std::env::var("JELLYFIN_USERNAME").change_context(Error)?,
|
||||
std::env::var("JELLYFIN_PASSWORD").change_context(Error)?,
|
||||
std::env::var("JELLYFIN_SERVER_URL").change_context(Error)?,
|
||||
"jello".to_string(),
|
||||
);
|
||||
.attach("Failed to parse Jellyfin Config")?;
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
fn jellyfin_config() -> JellyfinConfig {
|
||||
jellyfin_config_try().unwrap_or_else(|err| {
|
||||
eprintln!("Error loading Jellyfin configuration: {}", err);
|
||||
eprintln!("Error loading Jellyfin configuration: {:?}", err);
|
||||
std::process::exit(1);
|
||||
})
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
ui_iced::ui(jellyfin_config).change_context(Error)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user