exit-code

Crates.ioexit-code
lib.rsexit-code
version1.0.0
sourcesrc
created_at2017-06-04 09:06:30.172691
updated_at2017-08-02 14:52:22.704919
descriptionCommonly used exit codes for usage in applications.
homepagehttps://github.com/Fleshgrinder/rust-exit-code
repositoryhttps://github.com/Fleshgrinder/rust-exit-code
max_upload_size
id17661
size8,512
Richard Fussenegger (Fleshgrinder)

documentation

https://docs.rs/exit-code

README

Rust Exit Codes

Commonly used exit codes for usage in applications.

Using appropriate exit codes greatly helps users of applications to assert them in their own scripts and take appropriate actions based on the returned code. Simply using the catchall exit code 1 all the time does not help others in any way. Unless there is only a single source of error in the complete application, which is very unlikely.

Installation

Add the following to your Cargo.toml file:

[dependencies]
exit_codes = "1.0.0"

Usage

extern crate exit_code;

fn main() {
    use std::process::exit;
    use exit_code::SUCCESS;

    println!("Hello, World!");
    exit(SUCCESS);
}

This crate provides two additional functions that allow validation of exit codes:

  • is_reserved(exit_code) -> bool can be used to check if a given exit code has a reserved meaning in a shell, refer to the API documentation for the meaning of the reserved exit codes.
  • is_valid(exit_code) -> bool can be used to check if a given exit code is within the range [0..256] (anything below or beyond silently overflows).

References

Commit count: 5

cargo fmt