diff options
author | Guillaume Pasquet <dev@etenil.net> | 2022-02-16 13:56:40 +0000 |
---|---|---|
committer | Guillaume Pasquet <dev@etenil.net> | 2022-02-16 13:56:40 +0000 |
commit | 47fd1e1985faa8d3251674c4ea92e11797da5866 (patch) | |
tree | 0834fca8780992f075dfbe6b4146189874e238f6 | |
parent | 39b1ad964e03ec813c27708b2b1f8e952dfe3f00 (diff) |
Fix: pick up list of files instead of hard-coded thing
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/executor.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 23 |
4 files changed, 21 insertions, 8 deletions
@@ -36,7 +36,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "barb" -version = "0.1.0" +version = "0.1.1" dependencies = [ "clap 3.0.14", "jsonformat", @@ -1,6 +1,6 @@ [package] name = "barb" -version = "0.1.0" +version = "0.1.1" edition = "2018" license = "GPL-3.0-or-later" description = "Command-line tool to perform file-based HTTP(s) requests." 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); + } +} |