Skip to content

Commit

Permalink
chore(release): Release version 0.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Oct 31, 2024
2 parents 2607256 + a29dec9 commit 3441a7d
Show file tree
Hide file tree
Showing 9 changed files with 581 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0 OR MIT

[tool.bumpversion]
current_version = "0.8.3"
current_version = "0.8.4"

[[tool.bumpversion.files]]
filename = "CITATION.cff"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ All notable changes to this project will be documented in this file.
The format is based on https://keepachangelog.com/[Keep a Changelog], and this
project adheres to https://semver.org/[Semantic Versioning].

== {compare-url}/v0.8.3\...v0.8.4[0.8.4] - 2024-10-31

=== Added

* Implement `fmt::Octal`, `fmt::LowerHex`, `fmt::UpperHex`, `fmt::Binary`,
`fmt::LowerExp` and `fmt::UpperExp` for `ExitCode`
({pull-request-url}/129[#129])

== {compare-url}/v0.8.2\...v0.8.3[0.8.3] - 2024-10-30

=== Added
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ cff-version: 1.2.0
message: Please cite this software using these meta data.

# Version information.
date-released: 2024-10-30
version: 0.8.3
date-released: 2024-10-31
version: 0.8.4

# Project information.
abstract: The system exit codes as defined by <sysexits.h> for Rust
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[package]
name = "sysexits"
version = "0.8.3"
version = "0.8.4"
authors = ["Shun Sakai <sorairolake@protonmail.ch>"]
edition = "2021"
rust-version = "1.74.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
sysexits = "0.8.3"
sysexits = "0.8.4"
```

### Crate features
Expand Down
122 changes: 42 additions & 80 deletions src/exit_code.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-FileCopyrightText: 2022 Kevin Matthes
// SPDX-FileCopyrightText: 2022 Shun Sakai
// SPDX-FileCopyrightText: 2023 Kevin Matthes
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

Expand All @@ -9,10 +9,9 @@
mod consts;
mod convert;
mod fmt;
pub mod result;

use core::fmt;

/// `ExitCode` is a type that represents the system exit code constants as
/// defined by [`<sysexits.h>`].
///
Expand All @@ -26,7 +25,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::Ok as u8, 0);
/// assert_eq!(u8::from(ExitCode::Ok), 0);
/// ```
#[default]
Ok,
Expand All @@ -39,7 +38,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::Usage as u8, 64);
/// assert_eq!(u8::from(ExitCode::Usage), 64);
/// ```
Usage = 64,

Expand All @@ -51,7 +50,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::DataErr as u8, 65);
/// assert_eq!(u8::from(ExitCode::DataErr), 65);
/// ```
DataErr,

Expand All @@ -64,7 +63,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::NoInput as u8, 66);
/// assert_eq!(u8::from(ExitCode::NoInput), 66);
/// ```
NoInput,

Expand All @@ -76,7 +75,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::NoUser as u8, 67);
/// assert_eq!(u8::from(ExitCode::NoUser), 67);
/// ```
NoUser,

Expand All @@ -88,7 +87,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::NoHost as u8, 68);
/// assert_eq!(u8::from(ExitCode::NoHost), 68);
/// ```
NoHost,

Expand All @@ -101,7 +100,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::Unavailable as u8, 69);
/// assert_eq!(u8::from(ExitCode::Unavailable), 69);
/// ```
Unavailable,

Expand All @@ -113,7 +112,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::Software as u8, 70);
/// assert_eq!(u8::from(ExitCode::Software), 70);
/// ```
Software,

Expand All @@ -127,7 +126,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::OsErr as u8, 71);
/// assert_eq!(u8::from(ExitCode::OsErr), 71);
/// ```
///
/// [`getuid(2)`]: https://man.openbsd.org/getuid.2
Expand All @@ -141,7 +140,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::OsFile as u8, 72);
/// assert_eq!(u8::from(ExitCode::OsFile), 72);
/// ```
OsFile,

Expand All @@ -152,7 +151,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::CantCreat as u8, 73);
/// assert_eq!(u8::from(ExitCode::CantCreat), 73);
/// ```
CantCreat,

Expand All @@ -163,7 +162,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::IoErr as u8, 74);
/// assert_eq!(u8::from(ExitCode::IoErr), 74);
/// ```
IoErr,

Expand All @@ -176,7 +175,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::TempFail as u8, 75);
/// assert_eq!(u8::from(ExitCode::TempFail), 75);
/// ```
TempFail,

Expand All @@ -188,7 +187,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::Protocol as u8, 76);
/// assert_eq!(u8::from(ExitCode::Protocol), 76);
/// ```
Protocol,

Expand All @@ -202,7 +201,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::NoPerm as u8, 77);
/// assert_eq!(u8::from(ExitCode::NoPerm), 77);
/// ```
NoPerm,

Expand All @@ -213,7 +212,7 @@ pub enum ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::Config as u8, 78);
/// assert_eq!(u8::from(ExitCode::Config), 78);
/// ```
Config,
}
Expand All @@ -227,8 +226,8 @@ impl ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::Ok.is_success(), true);
/// assert_eq!(ExitCode::Usage.is_success(), false);
/// assert!(ExitCode::Ok.is_success());
/// assert!(!ExitCode::Usage.is_success());
/// ```
#[must_use]
#[inline]
Expand All @@ -244,8 +243,8 @@ impl ExitCode {
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(ExitCode::Ok.is_failure(), false);
/// assert_eq!(ExitCode::Usage.is_failure(), true);
/// assert!(!ExitCode::Ok.is_failure());
/// assert!(ExitCode::Usage.is_failure());
/// ```
#[must_use]
#[inline]
Expand Down Expand Up @@ -273,23 +272,6 @@ impl ExitCode {
}
}

impl fmt::Display for ExitCode {
/// Shows the integer representation of this `ExitCode`.
///
/// # Examples
///
/// ```
/// # use sysexits::ExitCode;
/// #
/// assert_eq!(format!("{}", ExitCode::Ok), "0");
/// assert_eq!(format!("{}", ExitCode::Usage), "64");
/// ```
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
u8::from(*self).fmt(f)
}
}

#[cfg(feature = "std")]
impl std::error::Error for ExitCode {}

Expand All @@ -305,6 +287,26 @@ impl std::process::Termination for ExitCode {
mod tests {
use super::*;

#[test]
fn exit_code() {
assert_eq!(ExitCode::Ok as u8, 0);
assert_eq!(ExitCode::Usage as u8, 64);
assert_eq!(ExitCode::DataErr as u8, 65);
assert_eq!(ExitCode::NoInput as u8, 66);
assert_eq!(ExitCode::NoUser as u8, 67);
assert_eq!(ExitCode::NoHost as u8, 68);
assert_eq!(ExitCode::Unavailable as u8, 69);
assert_eq!(ExitCode::Software as u8, 70);
assert_eq!(ExitCode::OsErr as u8, 71);
assert_eq!(ExitCode::OsFile as u8, 72);
assert_eq!(ExitCode::CantCreat as u8, 73);
assert_eq!(ExitCode::IoErr as u8, 74);
assert_eq!(ExitCode::TempFail as u8, 75);
assert_eq!(ExitCode::Protocol as u8, 76);
assert_eq!(ExitCode::NoPerm as u8, 77);
assert_eq!(ExitCode::Config as u8, 78);
}

#[test]
fn clone() {
assert_eq!(ExitCode::Ok.clone(), ExitCode::Ok);
Expand All @@ -317,26 +319,6 @@ mod tests {
assert_eq!(a, b);
}

#[test]
fn debug() {
assert_eq!(format!("{:?}", ExitCode::Ok), "Ok");
assert_eq!(format!("{:?}", ExitCode::Usage), "Usage");
assert_eq!(format!("{:?}", ExitCode::DataErr), "DataErr");
assert_eq!(format!("{:?}", ExitCode::NoInput), "NoInput");
assert_eq!(format!("{:?}", ExitCode::NoUser), "NoUser");
assert_eq!(format!("{:?}", ExitCode::NoHost), "NoHost");
assert_eq!(format!("{:?}", ExitCode::Unavailable), "Unavailable");
assert_eq!(format!("{:?}", ExitCode::Software), "Software");
assert_eq!(format!("{:?}", ExitCode::OsErr), "OsErr");
assert_eq!(format!("{:?}", ExitCode::OsFile), "OsFile");
assert_eq!(format!("{:?}", ExitCode::CantCreat), "CantCreat");
assert_eq!(format!("{:?}", ExitCode::IoErr), "IoErr");
assert_eq!(format!("{:?}", ExitCode::TempFail), "TempFail");
assert_eq!(format!("{:?}", ExitCode::Protocol), "Protocol");
assert_eq!(format!("{:?}", ExitCode::NoPerm), "NoPerm");
assert_eq!(format!("{:?}", ExitCode::Config), "Config");
}

#[test]
fn default() {
assert_eq!(ExitCode::default(), ExitCode::Ok);
Expand Down Expand Up @@ -603,26 +585,6 @@ mod tests {
assert_eq!(ExitCode::Config, ExitCode::Config);
}

#[test]
fn display() {
assert_eq!(format!("{}", ExitCode::Ok), format!("{}", 0));
assert_eq!(format!("{}", ExitCode::Usage), format!("{}", 64));
assert_eq!(format!("{}", ExitCode::DataErr), format!("{}", 65));
assert_eq!(format!("{}", ExitCode::NoInput), format!("{}", 66));
assert_eq!(format!("{}", ExitCode::NoUser), format!("{}", 67));
assert_eq!(format!("{}", ExitCode::NoHost), format!("{}", 68));
assert_eq!(format!("{}", ExitCode::Unavailable), format!("{}", 69));
assert_eq!(format!("{}", ExitCode::Software), format!("{}", 70));
assert_eq!(format!("{}", ExitCode::OsErr), format!("{}", 71));
assert_eq!(format!("{}", ExitCode::OsFile), format!("{}", 72));
assert_eq!(format!("{}", ExitCode::CantCreat), format!("{}", 73));
assert_eq!(format!("{}", ExitCode::IoErr), format!("{}", 74));
assert_eq!(format!("{}", ExitCode::TempFail), format!("{}", 75));
assert_eq!(format!("{}", ExitCode::Protocol), format!("{}", 76));
assert_eq!(format!("{}", ExitCode::NoPerm), format!("{}", 77));
assert_eq!(format!("{}", ExitCode::Config), format!("{}", 78));
}

#[test]
fn is_success_for_successful_termination() {
assert!(ExitCode::Ok.is_success());
Expand Down
Loading

0 comments on commit 3441a7d

Please sign in to comment.