aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs
index a35ad7d..6099020 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -31,6 +31,10 @@ struct Args {
}
impl Args {
+ pub fn print_req(&self) -> bool {
+ return !self.body
+ }
+
pub fn print_headers(&self) -> bool {
self.headers || self.all_headers || !self.body
}
@@ -47,13 +51,11 @@ impl Args {
self.all_headers
}
- pub fn files_iter(&self) -> Iter<String>
- {
+ pub fn files_iter(&self) -> Iter<String> {
self.files.iter()
}
- pub fn jq_filter(&self) -> &Option<String>
- {
+ pub fn jq_filter(&self) -> &Option<String> {
&self.filter
}
}
@@ -72,8 +74,9 @@ fn run_file(args: &Args, executor: &mut Executor, file_name: &String) -> Result<
fs::read_to_string(file_name.as_str())
.map_err(|_| format!("Failed to read file '{}'", file_name))?
.as_str(),
- ).map_err(|_| format!("Failed to parse file '{}'", file_name))?;
- let response = executor.execute(&bfile, args.req_headers())?;
+ )
+ .map_err(|_| format!("Failed to parse file '{}'", file_name))?;
+ let response = executor.execute(&bfile, args.print_req(), args.req_headers())?;
if args.print_headers() {
println!("{} {}", response.status(), response.status_text());
@@ -81,7 +84,7 @@ fn run_file(args: &Args, executor: &mut Executor, file_name: &String) -> Result<
println!(
"{}: {}",
header_name,
- // Header is guaranteed to exist
+ // Header is guaranteed to exist
response.header(header_name.as_str()).unwrap()
);
}
@@ -93,10 +96,7 @@ fn run_file(args: &Args, executor: &mut Executor, file_name: &String) -> Result<
"{}",
match args.raw_body() {
true => body,
- false => format_json(
- body.as_str(),
- Indentation::Default
- ),
+ false => format_json(body.as_str(), Indentation::Default),
}
);
}
@@ -112,7 +112,7 @@ fn main() {
for file in args.files_iter() {
match run_file(&args, &mut executor, file) {
Ok(()) => (),
- Err(err) => println!("{}", err)
+ Err(err) => println!("{}", err),
}
}
}