move outfly.toml to src/data/
This commit is contained in:
parent
00ce509935
commit
c56ae18f5a
31
src/var.rs
31
src/var.rs
|
@ -76,27 +76,32 @@ fn get_prefs_path() -> Option<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_prefs() -> Preferences {
|
pub fn load_prefs() -> Preferences {
|
||||||
let prefs_path = match get_prefs_path() {
|
let (toml, path) = match get_prefs_path() {
|
||||||
Some(path) => path,
|
Some(path) => {
|
||||||
None => {
|
let toml = fs::read_to_string(&path);
|
||||||
warn!("Found no preference file, using default preferences.");
|
match toml {
|
||||||
|
Ok(toml) => (toml, Some(path)),
|
||||||
|
Err(error) => {
|
||||||
|
error!("Failed to open preferences file '{path}': {error}");
|
||||||
return Preferences::default();
|
return Preferences::default();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
let toml = fs::read_to_string(&prefs_path);
|
}
|
||||||
let toml = match toml {
|
None => {
|
||||||
Ok(toml) => toml,
|
warn!("Found no preference file, using default preferences.");
|
||||||
Err(error) => {
|
(include_str!("data/outfly.toml").to_string(), None)
|
||||||
error!("Failed to open preferences file '{prefs_path}': {error}");
|
|
||||||
return Preferences::default();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match toml.parse::<DocumentMut>() {
|
match toml.parse::<DocumentMut>() {
|
||||||
Ok(doc) => {
|
Ok(doc) => {
|
||||||
match toml_edit::de::from_document::<Preferences>(doc) {
|
match toml_edit::de::from_document::<Preferences>(doc) {
|
||||||
Ok(mut pref) => {
|
Ok(mut pref) => {
|
||||||
info!("Loaded preference file from {prefs_path}");
|
if let Some(path) = &path {
|
||||||
pref.source_file = Some(prefs_path);
|
info!("Loaded preference file from {path}");
|
||||||
|
} else {
|
||||||
|
info!("Loaded preferences from internal defaults");
|
||||||
|
}
|
||||||
|
pref.source_file = path;
|
||||||
dbg!(&pref);
|
dbg!(&pref);
|
||||||
return pref;
|
return pref;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue