aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Pasquet <dev@etenil.net>2022-03-26 09:52:40 +0000
committerGuillaume Pasquet <dev@etenil.net>2022-03-26 09:52:40 +0000
commitf255e22c35da1dd374ef49b0300e6e6ca9c08a80 (patch)
treebeb84a62e263ffaca2e18cb279fba822ffe5afdf
parent6d60900a0bfb41a47744048c7980eefa15c572c8 (diff)
Fix #18 - Disable filters
-rw-r--r--TODO26
-rw-r--r--src/executor.rs7
-rw-r--r--src/main.rs11
3 files changed, 28 insertions, 16 deletions
diff --git a/TODO b/TODO
index c307705..9e9a2e9 100644
--- a/TODO
+++ b/TODO
@@ -1,24 +1,24 @@
-* Context [25%]
+* Context [100%]
** DONE Introduce context structure
-** TODO Populate from env variables
-** TODO Implement variable substitution in barbfiles
-** TODO Carry over context across requests
+** DONE Populate from env variables
+** DONE Implement variable substitution in barbfiles
+** DONE Carry over context across requests
-* JQ filtering [0%]
-** TODO Find a JQ-like library in rust
-** TODO Use library to extract data from requests
-** TODO Allow multiple named filters
-** TODO Store filter output in context
+* JQ filtering [100%]
+** DONE Find a JQ-like library in rust
+** DONE Use library to extract data from requests
+** DONE Allow multiple named filters
+** DONE Store filter output in context
* Support binary files [0%]
** TODO Have binary filepath as body
** TODO Output binary files to file system
** TODO Coerce filetype (to display seemingly binary files normally)
-* Command line options [0%]
-** TODO Multiple files on the command line
-** TODO Filter override
-** TODO Disable filtering altogether
+* Command line options [75%]
+** DONE Multiple files on the command line
+** DONE Filter override
+** DONE Disable filtering altogether
** TODO Override header
* Add curses-based manager
diff --git a/src/executor.rs b/src/executor.rs
index 0a6e855..4323bc0 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -130,6 +130,7 @@ impl Executor {
bfile: &BarbFile,
output: &BarbOutput,
filter: &Option<String>,
+ skip_filters: bool
) -> Result<(), String> {
let response = self.run(&bfile, self.make_req(&bfile, output))?;
//let response = executor.execute(&bfile, &output)?;
@@ -143,7 +144,11 @@ impl Executor {
}
output.end_resp_hdr();
- output.body(self.apply_filters(&bfile, response.into_string().unwrap(), filter)?);
+ if ! skip_filters {
+ output.body(self.apply_filters(&bfile, response.into_string().unwrap(), filter)?);
+ } else {
+ output.body(response.into_string().unwrap());
+ }
Ok(())
}
diff --git a/src/main.rs b/src/main.rs
index 0cd839c..151b277 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -24,6 +24,8 @@ struct Args {
filter: Option<String>,
#[clap(short, long)]
no_color: bool,
+ #[clap(short = 'F', long)]
+ no_filter: bool,
files: Vec<String>,
}
@@ -36,6 +38,10 @@ impl Args {
&self.filter
}
+ pub fn no_filter(&self) -> bool {
+ self.no_filter
+ }
+
pub fn output(&self) -> BarbOutput {
BarbOutput::new(
!self.body,
@@ -83,7 +89,8 @@ fn main() {
dependencies.dedup();
for dep in dependencies {
- match executor.execute(&dep, &output, args.jq_filter()) {
+ // Always enable filters on dependencies
+ match executor.execute(&dep, &output, args.jq_filter(), false) {
Ok(()) => (),
Err(err) => println!("{}", err),
}
@@ -95,7 +102,7 @@ fn main() {
continue;
}
- match executor.execute(&bfile.unwrap(), &output, args.jq_filter()) {
+ match executor.execute(&bfile.unwrap(), &output, args.jq_filter(), args.no_filter()) {
Ok(()) => (),
Err(err) => println!("{}", err),
}