diff --git a/src/config/mod.rs b/src/config/mod.rs index 27e1025..9b17854 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -11,9 +11,9 @@ pub mod validate_types; #[derive(Debug, Serialize, Deserialize, Default)] pub struct Config { - input: Vec, - output: HashMap, - title: String + pub input: Vec, + pub output: HashMap, + pub title: String } impl Config { diff --git a/src/input.rs b/src/input.rs new file mode 100644 index 0000000..a8d7e8d --- /dev/null +++ b/src/input.rs @@ -0,0 +1,13 @@ +use std::fs::File; +use std::io::Read; +use std::path::PathBuf; + + +pub fn read_input_files(files: Vec) -> String { + let mut input = String::new(); + for input_file_path in files.iter() { + let mut input_file = File::open(input_file_path).expect("Unable to open file"); + input_file.read_to_string(&mut input).expect("Failed to read file"); + } + return input; +} diff --git a/src/main.rs b/src/main.rs index 7cfef6c..28b5172 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,8 @@ extern crate serde_yaml; mod args; mod config; +mod process; +mod input; #[cfg(test)] mod tests; @@ -15,6 +17,7 @@ mod tests; fn main() { let args = args::get_matches(); if args.subcommand_name().unwrap() == "build" { - println!("{:?}", config::get_config()); + let config = config::get_config(); + process::build(config); } } diff --git a/src/process.rs b/src/process.rs new file mode 100644 index 0000000..363e959 --- /dev/null +++ b/src/process.rs @@ -0,0 +1,8 @@ +use input::read_input_files; +use config::Config; + + +pub fn build(config: Config) { + let input = read_input_files(config.input); + println!("{}", input); +}