From 16adafb8b915c414374e51fd3fb2ae000aa09f21 Mon Sep 17 00:00:00 2001 From: quak Date: Mon, 13 Jan 2025 20:49:03 +0100 Subject: [PATCH] fixed separators being printed with quotes --- config-parser/config-parser-common/src/common.rs | 6 +++--- .../src/generator_functions.rs | 1 + src/bookmarks.rs | 15 +++++---------- src/config.rs | 2 -- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/config-parser/config-parser-common/src/common.rs b/config-parser/config-parser-common/src/common.rs index 9a88a78..f3d48ca 100644 --- a/config-parser/config-parser-common/src/common.rs +++ b/config-parser/config-parser-common/src/common.rs @@ -27,10 +27,10 @@ pub fn parse_config_file(input: &String) -> std::io::Result = tokens[1].split(['\'', '\"']).collect::>().join(','); + // clean up value: remove quotes.. TODO: + let option = tokens[1].replace(&['\"', '\''][..], ""); - config.insert(tokens[0].to_string(), tokens[1].to_string()); + config.insert(tokens[0].to_string(), option); } } diff --git a/config-parser/config-parser-macro/src/generator_functions.rs b/config-parser/config-parser-macro/src/generator_functions.rs index 34e39e4..89d3d46 100644 --- a/config-parser/config-parser-macro/src/generator_functions.rs +++ b/config-parser/config-parser-macro/src/generator_functions.rs @@ -115,6 +115,7 @@ pub fn gen_config_assignments(fields: &Punctuated, config_map_name Ok(parsed) => { parsed }, + // TODO: implement warnings about errors here Err(_) => { self.#name.clone() }, diff --git a/src/bookmarks.rs b/src/bookmarks.rs index 1960e09..d622293 100644 --- a/src/bookmarks.rs +++ b/src/bookmarks.rs @@ -2,12 +2,12 @@ //! in said config file use std::collections::HashMap; -use std::env::var; use std::fs; use std::fs::File; use std::io::{Error, Result}; use std::path::PathBuf; use std::str::FromStr; +use dirs::config_dir; use super::config::*; use config_parser::{make_padding_string, apply_format}; @@ -28,17 +28,12 @@ impl Bookmarks { bookmarks: HashMap::::new(), }; // get home directory path - let home_dir = match var("HOME") { - Ok(value) => value, - Err(error) => return Err(Error::other(error.to_string())), - }; - // create PathBuf object from home dir path - bookmarks.conf_dir = match PathBuf::from_str(&home_dir) { - Ok(value) => value, - Err(error) => return Err(Error::other(error.to_string())), + bookmarks.conf_dir = match config_dir() { + Some(value) => value, + None => return Err(Error::other("-- failed to find configuration directory")), }; // expand home directory path to get configuration directory path - bookmarks.conf_dir.push(".config/navigate/"); + bookmarks.conf_dir.push("navigate/"); bookmarks.build_bookmarks()?; Ok(bookmarks) diff --git a/src/config.rs b/src/config.rs index 0513349..2cc303a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,8 +9,6 @@ use std::io::{Error, Result}; use std::path::PathBuf; use config_parser::*; -use crate::debug::debug_print; - #[derive(Debug, Clone)] pub struct Config { conf_file: PathBuf,