die
die is a simple Rust library to make it easy to handle errors and exit in command line programs.
# Cargo.toml
[]
= "0.2"
Example usage:
use Die;
// Result:
Ok.die; // unwraps to 1 successfully
Err.die; // prints `strange error` to stderr then exits with code 1
// Option:
Some.die; // unwraps to 1 successfully
None.die; // prints `none option` to stderr then exits with code 1
// custom error codes:
Err.die_code; // prints `strange error` to stderr then exits with code 4
None.die_code; // prints `none option` to stderr then exits with code 5
// die! macro:
die!; // prints message to stderr then exits with code 1
die!; // prints message to stderr then exits with code 2
die!; // prints message to stderr then exits with code 3
die!; // prints `argument -e must be 1` to stderr then exits with code 4
die!; // prints `argument -e must be 1` to stderr then exits with code 1
die!; // prints nothing, only exits with code 3
die!; // prints nothing, only exits with code 1
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in die by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.