#sysexit #cli #exit-codes

no-std exit-code

Commonly used exit codes for usage in applications

1 stable release

Uses old Rust 2015

1.0.0 Jun 4, 2017

#578 in Operating systems

Download history 63/week @ 2023-11-18 636/week @ 2023-11-25 714/week @ 2023-12-02 224/week @ 2023-12-09 156/week @ 2023-12-16 106/week @ 2023-12-23 25/week @ 2023-12-30 47/week @ 2024-01-06 58/week @ 2024-01-13 36/week @ 2024-01-20 26/week @ 2024-01-27 18/week @ 2024-02-03 46/week @ 2024-02-10 61/week @ 2024-02-17 59/week @ 2024-02-24 46/week @ 2024-03-02

217 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