diff --git a/src/config/config.rs b/src/config/config.rs new file mode 100644 index 0000000..5244dca --- /dev/null +++ b/src/config/config.rs @@ -0,0 +1,58 @@ +/* + DOWNFAV - Download Favourites + Copyright (C) 2020-2021 Julio Biason + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +use std::collections::HashMap; + +use directories::ProjectDirs; +use elefren::Data; + +/// The last seen favourite +struct Favourite { + last: String, +} + +/// Account configuration +struct AccountConfig { + favourite: Favourite, + mastodon: Data, +} + +/// Errors from the configuration +pub enum ConfigError { + /// The system can't figure out the path for the configuration file + CantFigureConfigPath, +} + +/// The main configuration +#[derive(serde_derive::Serialize, serde::derive::Deserialize, Debug)] +pub struct Config(HashMap); + +impl Config { + /// Figure out the filename for the configuration file. + fn filename() -> Result { + if let Some(proj_dirs) = + ProjectDirs::from("me", "JulioBiason", "downfav") + { + Ok(proj_dirs.config_dir()) + } else { + Error(ConfigError::CantFigureConfigPath) + } + } + + pub fn new() -> Self {} +} diff --git a/src/config/mod.rs b/src/config/mod.rs index ba4f523..12ac44e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -121,9 +121,6 @@ impl AccountConfig { } new_configuration } - - /// Add an account to the configuration - pub fn add_account() {} } impl From for AccountConfig {