aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Pasquet <dev@etenil.net>2022-02-16 13:56:40 +0000
committerGuillaume Pasquet <dev@etenil.net>2022-02-16 13:56:40 +0000
commit47fd1e1985faa8d3251674c4ea92e11797da5866 (patch)
tree0834fca8780992f075dfbe6b4146189874e238f6 /src
parent39b1ad964e03ec813c27708b2b1f8e952dfe3f00 (diff)
Fix: pick up list of files instead of hard-coded thing
Diffstat (limited to 'src')
-rw-r--r--src/executor.rs2
-rw-r--r--src/main.rs23
2 files changed, 19 insertions, 6 deletions
diff --git a/src/executor.rs b/src/executor.rs
index ef97ace..d330419 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -1,4 +1,4 @@
-use crate::barbfile::{BarbFile, Header};
+use crate::barbfile::BarbFile;
use std::collections::HashMap;
use ureq;
diff --git a/src/main.rs b/src/main.rs
index db517d1..f5abb69 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,7 @@ mod barbfile;
mod executor;
use jsonformat::{format_json, Indentation};
+use std::slice::Iter;
use barbfile::BarbFile;
use executor::{Context, Executor};
@@ -42,14 +43,16 @@ impl Args {
pub fn req_headers(&self) -> bool {
self.all_headers
}
-}
-fn main() {
- let args = Args::parse();
+ pub fn files_iter(&self) -> Iter<String>
+ {
+ self.files.iter()
+ }
+}
- let mut executor = Executor::new(Context::new(env::vars()));
+fn run_file(args: &Args, executor: &mut Executor, file_name: &String) {
let bfile = BarbFile::from_str(
- fs::read_to_string("test.barb")
+ fs::read_to_string(file_name.as_str())
.expect("Failed to read file")
.as_str(),
)
@@ -80,3 +83,13 @@ fn main() {
);
}
}
+
+fn main() {
+ let args = Args::parse();
+
+ let mut executor = Executor::new(Context::new(env::vars()));
+
+ for file in args.files_iter() {
+ run_file(&args, &mut executor, &file);
+ }
+}