Skip to content

Commit

Permalink
fix: properly handle clap try_parse errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Nov 27, 2023
1 parent c78709c commit 1f30675
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/clarinet-cli/src/frontend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,14 @@ pub fn main() {
));
}
}
println!("{}", e);
process::exit(1);

// handle --version, --help, etc
// see how to safely print clap errors here:
// https://github.com/clap-rs/clap/blob/21b671f689bc0b8d790dc8c42902c22822bf6f82/clap_builder/src/error/mod.rs#L233
let _ = e.print();
let _ = std::io::stdout().lock().flush();
let _ = std::io::stderr().lock().flush();
std::process::exit(e.exit_code());
}
};

Expand Down

0 comments on commit 1f30675

Please sign in to comment.