aboutsummaryrefslogtreecommitdiff
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
parent39b1ad964e03ec813c27708b2b1f8e952dfe3f00 (diff)
Fix: pick up list of files instead of hard-coded thing
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/executor.rs2
-rw-r--r--src/main.rs23
4 files changed, 21 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7ba665d..be9f08f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -36,7 +36,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "barb"
-version = "0.1.0"
+version = "0.1.1"
dependencies = [
"clap 3.0.14",
"jsonformat",
diff --git a/Cargo.toml b/Cargo.toml
index aa82567..4f2849c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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);
+ }
+}