fixed separators being printed with quotes

This commit is contained in:
2025-01-13 20:49:03 +01:00
parent f5197c6362
commit 16adafb8b9
4 changed files with 9 additions and 15 deletions
@@ -27,10 +27,10 @@ pub fn parse_config_file(input: &String) -> std::io::Result<std::collections::Ha
// println!("error in line'", line); // println!("error in line'", line);
continue; continue;
} }
//// clean up value: remove quotes.. TODO: // clean up value: remove quotes.. TODO:
//let mut options: Vec<&str> = tokens[1].split(['\'', '\"']).collect::<Vec<&str>>().join(','); let option = tokens[1].replace(&['\"', '\''][..], "");
config.insert(tokens[0].to_string(), tokens[1].to_string()); config.insert(tokens[0].to_string(), option);
} }
} }
@@ -115,6 +115,7 @@ pub fn gen_config_assignments(fields: &Punctuated<Field, Comma>, config_map_name
Ok(parsed) => { Ok(parsed) => {
parsed parsed
}, },
// TODO: implement warnings about errors here
Err(_) => { Err(_) => {
self.#name.clone() self.#name.clone()
}, },
+5 -10
View File
@@ -2,12 +2,12 @@
//! in said config file //! in said config file
use std::collections::HashMap; use std::collections::HashMap;
use std::env::var;
use std::fs; use std::fs;
use std::fs::File; use std::fs::File;
use std::io::{Error, Result}; use std::io::{Error, Result};
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
use dirs::config_dir;
use super::config::*; use super::config::*;
use config_parser::{make_padding_string, apply_format}; use config_parser::{make_padding_string, apply_format};
@@ -28,17 +28,12 @@ impl Bookmarks {
bookmarks: HashMap::<String, PathBuf>::new(), bookmarks: HashMap::<String, PathBuf>::new(),
}; };
// get home directory path // get home directory path
let home_dir = match var("HOME") { bookmarks.conf_dir = match config_dir() {
Ok(value) => value, Some(value) => value,
Err(error) => return Err(Error::other(error.to_string())), None => return Err(Error::other("-- failed to find configuration directory")),
};
// 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())),
}; };
// expand home directory path to get configuration directory path // expand home directory path to get configuration directory path
bookmarks.conf_dir.push(".config/navigate/"); bookmarks.conf_dir.push("navigate/");
bookmarks.build_bookmarks()?; bookmarks.build_bookmarks()?;
Ok(bookmarks) Ok(bookmarks)
-2
View File
@@ -9,8 +9,6 @@ use std::io::{Error, Result};
use std::path::PathBuf; use std::path::PathBuf;
use config_parser::*; use config_parser::*;
use crate::debug::debug_print;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Config { pub struct Config {
conf_file: PathBuf, conf_file: PathBuf,