diff --git a/src/config.rs b/src/config.rs
deleted file mode 100644
index ef90d0e..0000000
--- a/src/config.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use toml::{Table, Value};
-
-#[derive(Debug, Clone)]
-pub struct Config {
- pub build_dir: String,
- pub compile_commands: bool,
- pub compile_commands_target: String,
-}
-
-impl Config {
- pub fn get_default() -> Self {
- Config {
- build_dir: String::from("build"),
- compile_commands: false,
- compile_commands_target: String::from(""),
- }
- }
- pub fn set(&mut self, table: &Table) {
- for k in table.keys() {
- match &*k.to_owned() {
- "build_dir" => {
- if let Value::String(s) = table.get(k).unwrap() {
- self.build_dir = s.to_owned();
- } else {
- panic!("error parsing config table: {k} invalid type, must be a string.");
- }
- }
- "compile_commands" => {
- if let Value::Boolean(b) = table.get(k).unwrap() {
- //eprintln!("warn: config.compile_commands has no functionality (yet)");
- self.compile_commands = *b;
- } else {
- panic!("error parsing config table: {k} invalid type, must be a boolean.");
- }
- }
- "compile_commands_target" => {
- if let Value::String(s) = table.get(k).unwrap() {
- self.compile_commands_target = s.to_owned();
- } else {
- panic!("error parsing config table: {k} invalid type, must be a string.");
- }
- }
- _ => panic!("error parsing config table: unrecognized key {k}."),
- }
- }
- }
-}
diff --git a/src/config_file_parsing.rs b/src/config_file_parsing.rs
new file mode 100644
index 0000000..ca4cb24
--- /dev/null
+++ b/src/config_file_parsing.rs
@@ -0,0 +1,106 @@
+use std::fmt::Display;
+
+use toml::{Table, Value};
+
+#[derive(Debug)]
+pub struct ConfigFileError<'a> {
+ pub key_path: String,
+ pub message: &'a str,
+}
+
+impl Display for ConfigFileError<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(
+ f,
+ "config file error: key {}: {}.",
+ self.key_path, self.message
+ )
+ }
+}
+
+pub fn get_key_as_str<'a>(
+ table: &'a Table,
+ key: &str,
+ key_path: String,
+) -> Result