diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-01-26 17:04:00 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-01-26 17:04:00 +0100 |
| commit | 4064639d3c3e25760ef43781feca77332cfbe5eb (patch) | |
| tree | 77ce2883e5569bd4de5e1408b41c9d6d556a11c6 /src/configuration.rs | |
| parent | fda55240fb06c55a7552ef7ded8c17ee56ce9f49 (diff) | |
Run lint / format
Diffstat (limited to 'src/configuration.rs')
| -rw-r--r-- | src/configuration.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/configuration.rs b/src/configuration.rs index 55443eb..56d60d9 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -1,9 +1,9 @@ +use serde::{Deserialize, Serialize}; +use serde_json; use std::env; use std::fs::{create_dir_all, write, File}; use std::io::{Read, Result}; use std::path::PathBuf; -use serde::{Deserialize, Serialize}; -use serde_json; const CONFIG_ENV_VARIABLE: &str = "LYRICLI_CONFIG_DIRECTORY"; const CONFIG_DEFAULT_LOCATION: &str = "XDG_CONFIG_HOME"; @@ -13,13 +13,11 @@ const CONFIG_FILENAME: &str = "lyricli.conf"; #[derive(Serialize, Deserialize, Debug)] pub struct Configuration { - enabled_sources: Vec<String> + enabled_sources: Vec<String>, } impl Configuration { - - pub fn new() -> Self { - + pub fn new() -> Self { if let Some(configuration) = Configuration::read() { return configuration; } @@ -56,8 +54,8 @@ impl Configuration { enabled_sources: vec![ "apple_music".to_string(), "spotify".to_string(), - "strawberry".to_string() - ] + "strawberry".to_string(), + ], } } @@ -91,9 +89,13 @@ impl Configuration { Ok(directory) => PathBuf::from(directory), Err(_) => match env::var("HOME") { Ok(directory) => PathBuf::from(directory).join(CONFIG_FALLBACK_LOCATION), - Err(_) => panic!("Could not find required directory, {} or {} should be set and readable.", CONFIG_ENV_VARIABLE, CONFIG_DEFAULT_LOCATION), + Err(_) => panic!( + "Could not find required directory, {} or {} should be set and readable.", + CONFIG_ENV_VARIABLE, CONFIG_DEFAULT_LOCATION + ), }, }, - }.join(CONFIG_SUBDIRECTORY) + } + .join(CONFIG_SUBDIRECTORY) } } |