Vergessene Dateien
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
use anyhow::{anyhow, Result };
|
||||
use directories::ProjectDirs;
|
||||
|
||||
pub struct Config {
|
||||
pub database_file: String,
|
||||
pub default_sheet: String,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn build() -> Result<Config> {
|
||||
let proj_dirs = ProjectDirs::from("de","schacht-analyse","timetracker")
|
||||
.ok_or(anyhow!("Couldn't get project directories"))?;
|
||||
|
||||
let data_dir = proj_dirs.data_dir();
|
||||
let mut db_file = data_dir.to_path_buf();
|
||||
|
||||
db_file.push("database.db");
|
||||
|
||||
if let Some(db_file_str) = db_file.to_str() {
|
||||
return Ok(Config {
|
||||
database_file: db_file_str.to_string(),
|
||||
default_sheet: "default".to_string(),
|
||||
});
|
||||
}
|
||||
Err(anyhow!("Couldn't get database file"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user