1 stable release

Uses old Rust 2015

1.0.0 Jun 4, 2017

#725 in Command-line interface

Download history 46/week @ 2024-03-11 51/week @ 2024-03-18 56/week @ 2024-03-25 91/week @ 2024-04-01 43/week @ 2024-04-08 74/week @ 2024-04-15 61/week @ 2024-04-22 48/week @ 2024-04-29 49/week @ 2024-05-06 59/week @ 2024-05-13 59/week @ 2024-05-20 53/week @ 2024-05-27 49/week @ 2024-06-03 45/week @ 2024-06-10 46/week @ 2024-06-17 57/week @ 2024-06-24

204 downloads per month
Used in 3 crates

Unlicense

8KB

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

No runtime deps