Skip to content

Commit

Permalink
debug: add --quiet flag
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed Mar 5, 2020
1 parent db67087 commit 934e6e7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion regex-debug/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Options:
extracted.
--searcher Show the debug output for the literal searcher
constructed by the literals found.
--quiet Show less output.
";

#[derive(Deserialize)]
Expand Down Expand Up @@ -80,6 +81,7 @@ struct Args {
flag_lcp: bool,
flag_lcs: bool,
flag_searcher: bool,
flag_quiet: bool,
}

type Result<T> = result::Result<T, Box<dyn error::Error + Send + Sync>>;
Expand Down Expand Up @@ -214,7 +216,11 @@ fn cmd_compile(args: &Args) -> Result<()> {
.dfa(args.flag_dfa)
.reverse(args.flag_dfa_reverse);
let prog = compiler.compile(&exprs)?;
print!("{:?}", prog);
if !args.flag_quiet {
print!("{:?}", prog);
} else {
println!("instruction count: {}", prog.insts.len());
}
Ok(())
}

Expand Down

0 comments on commit 934e6e7

Please sign in to comment.