diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-11-29 20:48:12 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-11-29 20:48:12 +0300 |
| commit | 5319e24d9f7b43dbfdfd368ea5ac467970061cd2 (patch) | |
| tree | 89eb1cb8f17962fe0f1bb8b97368a62875a60ded /src/cfg | |
| parent | d10ac4cc08d679e7971296b79c6eafadcdbc78de (diff) | |
Minor warnings fixed, implemented codeberg pages action
Diffstat (limited to 'src/cfg')
| -rw-r--r-- | src/cfg/config.rs | 63 | ||||
| -rw-r--r-- | src/cfg/mod.rs | 2 |
2 files changed, 38 insertions, 27 deletions
diff --git a/src/cfg/config.rs b/src/cfg/config.rs index ffccbad..cf6188e 100644 --- a/src/cfg/config.rs +++ b/src/cfg/config.rs @@ -1,5 +1,5 @@ -use std::fs; use serde::{Deserialize, Serialize}; +use std::fs; use toml; #[derive(Debug, Deserialize, Serialize)] @@ -9,16 +9,15 @@ pub enum Loglevel { Debug, Info, Warn, - Error + Error, } - /// `mesk.toml` configuration fields here #[derive(Deserialize, Debug, Serialize)] pub struct Config { - pub repo: Repo, - pub log: Log, - pub paths: Paths, + pub repo: Repo, + pub log: Log, + pub paths: Paths, } #[derive(Deserialize, Debug, Serialize)] @@ -29,29 +28,28 @@ pub struct Log { pub log_level: Loglevel, } -// Rename needed for editing mesk.toml file fields but dont touch code. +// Rename needed for editing mesk.toml file fields but dont touch code. #[derive(Deserialize, Debug, Serialize)] pub struct Repo { - #[serde(rename = "repo_url")] + #[serde(rename = "repo_url")] pub repo_url: String, - #[serde(rename = "auto_update")] + #[serde(rename = "auto_update")] pub auto_update: bool, #[serde(rename = "destination")] pub destination: (String, String), -// #[serde(rename = "arch")] -// pub arch = arch; + // #[serde(rename = "arch")] + // pub arch = arch; } #[derive(Deserialize, Debug, Serialize)] pub struct Paths { - #[serde(rename = "cache_dir")] + #[serde(rename = "cache_dir")] pub cache_dir: String, - #[serde(rename = "build_dir")] + #[serde(rename = "build_dir")] pub build_dir: String, } impl Config { - /// Parse the /etc/mesk.toml file and return the Config object. /// /// This function reads the /etc/mesk.toml file, parses it and returns the Config object. @@ -61,17 +59,15 @@ impl Config { Ok(result) } - /// Return the default configuration as a toml string. /// /// This function returns the default configuration as a toml string. pub fn default() -> Result<String, toml::ser::Error> { let default: Config = Config { repo: Repo { - repo_url: format!("https://mesk.anthrill.i2p/repo/{}/", - std::env::consts::ARCH), + repo_url: format!("https://mesk.anthrill.i2p/repo/{}/", std::env::consts::ARCH), auto_update: true, - destination: (String::from("mesk"), String::from("mesk")), + destination: (String::from("mesk"), String::from("mesk")), // Its a hurt place, you need to generate destinations by i2pd and paste here (to mesk.toml) // Better to leave it empty or set it to (mesk, mesk), now destination conn not implemented }, @@ -89,25 +85,40 @@ impl Config { Ok(toml_str) } - pub fn generate(repo: &Option<String>, cachedir: &Option<String>, buildir: &Option<String>) -> Result<String, toml::ser::Error> { + pub fn generate( + repo: &Option<String>, + cachedir: &Option<String>, + buildir: &Option<String>, + ) -> Result<String, toml::ser::Error> { let generator: Config = Config { repo: Repo { - repo_url: if repo.is_none() { format!("https://mesk.anthrill.i2p/repo/{}/", std::env::consts::ARCH ) } else { repo.clone().unwrap() }, + repo_url: if repo.is_none() { + format!("https://mesk.anthrill.i2p/repo/{}/", std::env::consts::ARCH) + } else { + repo.clone().unwrap() + }, auto_update: true, - destination: (String::from("mesk"), String::from("mesk")), + destination: (String::from("mesk"), String::from("mesk")), }, log: Log { log_file: String::from("/var/log/mesk.log"), log_level: Loglevel::Info, }, paths: Paths { - cache_dir: if cachedir.is_none() { String::from("/var/cache/mesk") } else { cachedir.clone().unwrap() }, - build_dir: if buildir.is_none() { String::from("/var/cache/mesk/build") } else { buildir.clone().unwrap() }, - - /* + cache_dir: if cachedir.is_none() { + String::from("/var/cache/mesk") + } else { + cachedir.clone().unwrap() + }, + build_dir: if buildir.is_none() { + String::from("/var/cache/mesk/build") + } else { + buildir.clone().unwrap() + }, + /* FIXME: I can leave this parameter, but I think it would be better to make the build path in the /var/cache/mesk/$pkgname-$pkgver/BUILD/ - */ + */ }, }; Ok(toml::to_string(&generator)?) diff --git a/src/cfg/mod.rs b/src/cfg/mod.rs index b1ca24c..ef68c36 100644 --- a/src/cfg/mod.rs +++ b/src/cfg/mod.rs @@ -1 +1 @@ -pub mod config;
\ No newline at end of file +pub mod config; |
