diff --git a/src/exit_codes.rs b/src/exit_codes.rs index 257f0b2..da0c125 100644 --- a/src/exit_codes.rs +++ b/src/exit_codes.rs @@ -1,4 +1,13 @@ -/// exit code 1 represents a general error -pub const ERROR: i32 = 1; -/// exit code 130 represents a process killed by signal SIGINT -pub const SIGINT: i32 = 130; +pub enum ExitCode { + Error, + Sigint, +} + +impl Into for ExitCode { + fn into(self) -> i32 { + match self { + ExitCode::Error => 1, + ExitCode::Sigint => 130, + } + } +} diff --git a/src/internal.rs b/src/internal.rs index 5340878..3cce716 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -214,12 +214,6 @@ fn hir_has_uppercase_char(hir: &Hir) -> bool { /// Maximum size of the output buffer before flushing results to the console pub const MAX_BUFFER_LENGTH: usize = 1000; -/// Exit code representing a general error -pub const EXITCODE_ERROR: i32 = 1; - -/// Exit code representing that the process was killed by SIGINT -pub const EXITCODE_SIGINT: i32 = 130; - /// Traverse args_os, looking for -exec and replacing it with --exec. /// /// # Returns diff --git a/src/main.rs b/src/main.rs index 69d8656..64fe140 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,7 @@ extern crate regex_syntax; mod app; mod exec; +mod exit_codes; pub mod fshelper; mod internal; pub mod lscolors; diff --git a/src/output.rs b/src/output.rs index 07f6044..2a7620b 100644 --- a/src/output.rs +++ b/src/output.rs @@ -6,8 +6,9 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use exit_codes::ExitCode; use fshelper::is_executable; -use internal::{FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT}; +use internal::FdOptions; use lscolors::LsColors; use std::io::{self, Write}; @@ -44,7 +45,7 @@ pub fn print_entry(entry: &PathBuf, config: &FdOptions, wants_to_quit: &Arc, config: Arc) { receiver_thread.join().unwrap(); if wants_to_quit.load(Ordering::Relaxed) { - process::exit(EXITCODE_SIGINT); + process::exit(ExitCode::Sigint.into()); } }