From a869fe7f3f82ca2a45c189bd38dcbf487e0d5734 Mon Sep 17 00:00:00 2001 From: Vincent Foley Date: Sat, 1 Sep 2018 18:22:19 -0400 Subject: [PATCH] Make handling of output_fn clearer --- src/main.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index fcabd28..4ef22f2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,6 +74,7 @@ fn main() { let max_per_line = value_t!(matches, "max_per_line", usize).unwrap(); let verbose = matches.is_present("verbose"); let parse_only = matches.is_present("parse"); + let json = matches.is_present("json"); let transform_proplists = matches.is_present("transform-proplists"); let parse_fn = @@ -84,20 +85,15 @@ fn main() { } else { parse_bert1 }; - let output_fn = - if matches.is_present("json") { - if transform_proplists { - pp_json_proplist - } else { - pp_json - } - } else { - if transform_proplists { - eprintln!("{}: warning: --transform-proplists is only valid with the --json flag", - PROG_NAME); - } + let output_fn = match (json, transform_proplists) { + (true, false) => pp_json, + (true, true) => pp_json_proplist, + (false, false) => pp_bert, + (false, true) => { + eprintln!("{}: --transform-proplists is only valid with the --json flag", PROG_NAME); pp_bert - }; + } + }; let mut return_code = 0; for file in files {