Major update
too lazy to describe
This commit is contained in:
@@ -7,6 +7,7 @@ license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
[dependencies]
|
||||
xmpd-cliargs.path = "../xmpd-cliargs"
|
||||
anyhow.workspace = true
|
||||
camino.workspace = true
|
||||
egui.workspace = true
|
||||
|
||||
29
xmpd-settings/src/cache.rs
Normal file
29
xmpd-settings/src/cache.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use camino::Utf8PathBuf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Cache {
|
||||
#[serde(default="Cache::default_cache_path")]
|
||||
pub cache_path: Utf8PathBuf,
|
||||
#[serde(default="Cache::default_manifest_path")]
|
||||
pub manifest_path: Utf8PathBuf,
|
||||
}
|
||||
|
||||
impl Default for Cache {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
cache_path: Self::default_cache_path(),
|
||||
manifest_path: Self::default_manifest_path(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Cache {
|
||||
fn default_cache_path() -> Utf8PathBuf {
|
||||
Utf8PathBuf::from("./cache")
|
||||
}
|
||||
fn default_manifest_path() -> Utf8PathBuf {
|
||||
Utf8PathBuf::from("./manifest.json")
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ use tooling::Tooling;
|
||||
|
||||
pub mod theme;
|
||||
pub mod tooling;
|
||||
pub mod cache;
|
||||
|
||||
lazy_static::lazy_static!(
|
||||
static ref SETTINGS: Arc<Mutex<Settings>> = Arc::new(Mutex::new(Settings::default()));
|
||||
@@ -20,6 +21,8 @@ pub struct Settings {
|
||||
pub theme: Theme,
|
||||
#[serde(default)]
|
||||
pub tooling: Tooling,
|
||||
#[serde(default)]
|
||||
pub cache_settings: cache::Cache
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
@@ -54,6 +57,16 @@ impl Settings {
|
||||
self.settings_path = path;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
pub fn load_cli_args(&mut self, cli_args: &xmpd_cliargs::CliArgs) {
|
||||
if let Some(mp) = cli_args.manifest_path() {
|
||||
self.cache_settings.manifest_path = mp;
|
||||
}
|
||||
if let Some(cp) = cli_args.cache_path() {
|
||||
self.cache_settings.cache_path = cp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user