Skip to content

Commit

Permalink
Make handling of output_fn clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
gnuvince committed Sep 1, 2018
1 parent 7f27c7f commit a869fe7
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 {
Expand Down

0 comments on commit a869fe7

Please sign in to comment.