5 stable releases

Uses old Rust 2015

1.1.2 Jun 18, 2017
1.1.1 Jun 11, 2017
1.0.1 May 27, 2017
1.0.0 May 25, 2017

#476 in Operating systems

Download history 26327/week @ 2024-03-14 24313/week @ 2024-03-21 24305/week @ 2024-03-28 25162/week @ 2024-04-04 25871/week @ 2024-04-11 25830/week @ 2024-04-18 26807/week @ 2024-04-25 24910/week @ 2024-05-02 28179/week @ 2024-05-09 26351/week @ 2024-05-16 25142/week @ 2024-05-23 28527/week @ 2024-05-30 26127/week @ 2024-06-06 25790/week @ 2024-06-13 25523/week @ 2024-06-20 20823/week @ 2024-06-27

103,911 downloads per month
Used in 206 crates (173 directly)

Apache-2.0

7KB

ghit.me Build Status Crates.io

exitcode

System exit code constants as defined by sysexits.h

Documentation is available here

Installing from crates.io

[dependencies]
exitcode = "1.1.2"

Example

extern crate exitcode;

use std::process;

pub fn parse_int_or_return_error_exitcode(s: String) -> Result<i32, exitcode::ExitCode> {
    match s.parse::<i32>() {
        Ok(i) => Ok(i),
        Err(_) => Err(exitcode::USAGE)
    }

}

pub fn main() {

    match parse_int_or_return_error_exitcode("123".to_string()) {
        Ok(i) => println!("Parsed: {}", i),
        Err(code) => {
            println!("Parse error.  Exiting with code: {}", code);
            process::exit(code);
        }
    }

    match parse_int_or_return_error_exitcode("foo".to_string()) {
        Ok(i) => println!("Parsed: {}", i),
        Err(code) => {
            println!("Parse error.  Exiting with code: {}", code);
            process::exit(code);
        }
    }

    println!("Exiting with code: {}", exitcode::OK);
    process::exit(exitcode::OK);

}

No runtime deps