1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
//! ## Features //! //! - `i32` newtype for exit codes //! - Can represent any valid exit code //! - Type safe, operations are restricted to what is valid for exit codes //! - Includes standard exit codes and signal exit codes //! - Integrate with `main`, `std::process`, and `std::io::Error` //! - Supports exiting silently (error message reported through another means) //! //! ## Install //! //! Add to your `Cargo.toml`: //! //! ```toml //! [dependencies] //! proc-exit = "0.1" //! ``` //! //! Feature flags: //! - `portable`: Coerce exit codes to `u8` for consistent, cross-platform, behavior //! //! # Example //! //! ``` //! fn main() { //! // Simple but Macro-less `main` //! // - Fast compiles //! // - Composable with other features //! use proc_exit::ProcessExitResultExt; //! run().process_exit(); //! } //! //! fn run() -> Result<(), proc_exit::Exit> { //! // Integrates directly with `std::io::Error`, returning the right exit code. //! let exit_status = std::process::Command::new("true") //! .status()?; //! // Can pass `Command` exit codes right up //! proc_exit::Code::from_status(exit_status).ok()?; //! //! proc_exit::Code::SUCCESS.ok() //! } //! ``` //! //! ## Relevant crates //! //! Other crates that might be useful in testing command line programs. //! - [duct][duct] for orchestrating multiple processes. //! - or [commandspec][commandspec] for easier writing of commands //! - [rexpect][rexpect] for controlling interactive programs. //! - [`assert_cmd`][assert_cmd] can be reused to simplify controlling CLIs //! //! [duct]: https://crates.io/crates/duct //! [rexpect]: https://crates.io/crates/rexpect //! [assert_cmd]: https://crates.io/crates/assert_cmd //! [commandspec]: https://crates.io/crates/commandspec //! //! ## Related crates //! //! Some crates that fill a similar role include: //! - [sysexit][sysexit] //! - Uses an enum, making certain states unpresentable //! - Includes signals //! - Integrates with `std::process` and `std::io::Error` //! - Doesn't integrate with `main` //! - [exit-code][exit-code] //! - `i32` constants and helper methods //! - Doesn't include signals //! - Doesn't integrate with `main`, `std::process`, or `std::io::Error` //! - [exitcode][exitcode] //! - `i32` constants and helper methods //! - Doesn't include signals //! - Doesn't integrate with `main`, `std::process`, or `std::io::Error` //! - [exitfailure][exitfailure] //! - Allows `Display`able errors to be used with [`?` in `main()`](https://github.com/rust-lang/rust/issues/43301) //! //! [sysexit]: https://crates.io/crates/sysexit //! [exit-code]: https://crates.io/crates/exit-code //! [exitcode]: https://crates.io/crates/exitcode //! [exitfailure]: https://crates.io/crates/exitfailure //! //! ## References //! //! As a basis it encodes the exit codes of [sysexits(3)][sysexits] from OpenBSD (64-78), exit statuses used by [bash][appendix-e], //! supplemented by codes created by shells when the command is terminated //! by a fatal signal. When the fatal signal is a number _N_, the latter //! follows bash's strategy of using the value 128 + _N_ as the exit status. //! This means that the `SIGHUP` (1) signal will be recognised as the exit code //! for the number 129. Signal codes were taken from [wikipedia](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGALRM) //! //! [sysexits]: http://tldp.org/LDP/abs/html/exitcodes.html //! [appendix-e]: http://tldp.org/LDP/abs/html/exitcodes.html mod code; mod exit; pub use code::Code; pub use exit::Exit; pub use exit::ProcessExitResultExt; pub use exit::WithCodeResultExt;