Read input files
This commit is contained in:
parent
5953f2b76b
commit
54d827fa74
4 changed files with 28 additions and 4 deletions
|
@ -11,9 +11,9 @@ pub mod validate_types;
|
|||
|
||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||
pub struct Config {
|
||||
input: Vec<PathBuf>,
|
||||
output: HashMap<String, PathBuf>,
|
||||
title: String
|
||||
pub input: Vec<PathBuf>,
|
||||
pub output: HashMap<String, PathBuf>,
|
||||
pub title: String
|
||||
}
|
||||
|
||||
impl Config {
|
||||
|
|
13
src/input.rs
Normal file
13
src/input.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
pub fn read_input_files(files: Vec<PathBuf>) -> 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;
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
8
src/process.rs
Normal file
8
src/process.rs
Normal file
|
@ -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);
|
||||
}
|
Reference in a new issue