Feat: clean the codebase as much as possible
This commit is contained in:
@@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::state::{ColorScheme, MainLayout};
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
const APP_NAME: &str = "cagire";
|
||||
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
@@ -116,6 +117,7 @@ impl Default for LinkSettings {
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
#[cfg(feature = "cli")]
|
||||
pub fn load() -> Self {
|
||||
let mut settings: Self = confy::load(APP_NAME, None).unwrap_or_default();
|
||||
if settings.audio.channels == 0 {
|
||||
@@ -127,10 +129,19 @@ impl Settings {
|
||||
settings
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "cli"))]
|
||||
pub fn load() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub fn save(&self) {
|
||||
if let Err(e) = confy::store(APP_NAME, None, self) {
|
||||
eprintln!("Failed to save settings: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "cli"))]
|
||||
pub fn save(&self) {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user