Compare commits

..

5 Commits

Author SHA1 Message Date
be0d62a8c5 tsk-54: Version bump
All checks were successful
Rust Build / Check (pull_request) Successful in 41s
Rust Build / Test Suite (pull_request) Successful in 40s
Rust Build / Rustfmt (pull_request) Successful in 33s
Rust Build / Clippy (pull_request) Successful in 42s
Rust Build / build (pull_request) Successful in 47s
2025-10-22 13:59:20 -04:00
5014fcd641 tsk-54: More refactoring 2025-10-22 13:59:08 -04:00
351fa05466 tsk-54: More refactoring 2025-10-22 13:56:01 -04:00
a907547b2d tsk-54: Moving some code around 2025-10-22 13:49:45 -04:00
1818faac87 tsk-54: Removed hard coded filename 2025-10-22 13:45:19 -04:00
4 changed files with 14 additions and 40 deletions

2
Cargo.lock generated
View File

@@ -1322,7 +1322,7 @@ dependencies = [
[[package]]
name = "songparser"
version = "0.4.9"
version = "0.4.8"
dependencies = [
"futures",
"icarus_envy",

View File

@@ -1,6 +1,6 @@
[package]
name = "songparser"
version = "0.4.9"
version = "0.4.8"
edition = "2024"
rust-version = "1.90"

View File

@@ -3,25 +3,4 @@ pub struct App {
pub uri: String,
pub auth_uri: String,
pub token: icarus_models::login_result::LoginResult,
pub root_directory: String,
}
impl App {
pub fn does_root_directory_exists(&self) -> bool {
let path = std::path::Path::new(&self.root_directory);
if path.exists() { path.is_dir() } else { false }
}
}
pub async fn initialize_app_config() -> App {
App {
uri: icarus_envy::environment::get_icarus_base_api_url()
.await
.value,
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url()
.await
.value,
root_directory: icarus_envy::environment::get_root_directory().await.value,
..Default::default()
}
}

View File

@@ -11,27 +11,22 @@ pub const SECONDS_TO_SLEEP: u64 = 5;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut app = config::initialize_app_config().await;
let mut app = config::App {
uri: icarus_envy::environment::get_icarus_base_api_url()
.await
.value,
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url()
.await
.value,
..Default::default()
};
println!("Base URL: {:?}", app.uri);
println!("Auth URL: {:?}", app.auth_uri);
if !app.does_root_directory_exists() {
eprintln!("Root directory does not exist");
println!("Attempting to create directory");
let path = std::path::Path::new(&app.root_directory);
match std::fs::create_dir(path) {
Ok(_) => {
println!("Directory created");
}
Err(err) => {
eprintln!("Error creating directory: {err:?}");
std::process::exit(-1);
}
match auth::get_token(&app).await {
Ok(login_result) => {
app.token = login_result;
}
}
app.token = match auth::get_token(&app).await {
Ok(login_result) => login_result,
Err(err) => {
eprintln!("Error: {err:?}");
std::process::exit(-1);