MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / render_and_exit

Function render_and_exit

atomic-cli/src/agent_error.rs:723–737  ·  view source on GitHub ↗

Terminal handler for `main`. clap's own display kinds (`--help`, `--version`, and the `arg_required_else_help` variant) are passed through untouched, including clap's original exit code. Everything else is re-rendered and exits 2, which means the command did not run.

(err: clap::Error, root: &clap::Command, argv: &[OsString])

Source from the content-addressed store, hash-verified

721/// clap's original exit code. Everything else is re-rendered and exits 2, which
722/// means the command did not run.
723pub fn render_and_exit(err: clap::Error, root: &clap::Command, argv: &[OsString]) -> ! {
724 match err.kind() {
725 ErrorKind::DisplayHelp
726 | ErrorKind::DisplayVersion
727 | ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand => {
728 let _ = err.print();
729 std::process::exit(err.exit_code());
730 }
731 _ => {
732 let output = render(&err, root, argv);
733 write_ignoring_errors(std::io::stderr().lock(), &output);
734 std::process::exit(2);
735 }
736 }
737}
738
739#[cfg(test)]
740mod tests {

Callers 1

mainFunction · 0.85

Calls 4

write_ignoring_errorsFunction · 0.85
renderFunction · 0.70
kindMethod · 0.45
exit_codeMethod · 0.45

Tested by

no test coverage detected