Skip to main content

hx_core/
lib.rs

1//! Core types and orchestration for hx.
2//!
3//! This crate provides shared types, error handling, and command execution
4//! utilities used across all hx crates.
5
6pub mod command;
7pub mod diagnostic;
8pub mod env;
9pub mod error;
10pub mod version;
11
12pub use command::{CommandOutput, CommandRunner};
13pub use diagnostic::{
14    DiagnosticReport, DiagnosticSeverity, GhcDiagnostic, QuickFix, SourceSpan, TextEdit,
15};
16pub use env::EnvVars;
17pub use error::{Error, ErrorCode, Fix, Result};
18pub use version::Version;
19
20/// Exit codes for hx CLI.
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22#[repr(u8)]
23pub enum ExitCode {
24    /// Success
25    Success = 0,
26    /// General error
27    GeneralError = 1,
28    /// Usage error (bad arguments)
29    UsageError = 2,
30    /// Configuration error
31    ConfigError = 3,
32    /// Toolchain error
33    ToolchainError = 4,
34    /// Build/test failure
35    BuildError = 5,
36}
37
38impl From<ExitCode> for i32 {
39    fn from(code: ExitCode) -> Self {
40        code as i32
41    }
42}
43
44impl From<ExitCode> for std::process::ExitCode {
45    fn from(code: ExitCode) -> Self {
46        std::process::ExitCode::from(code as u8)
47    }
48}