opencode-ralph-loop-cli 0.1.0

Scaffolder CLI for OpenCode Ralph Loop plugin — one command setup
Documentation
use thiserror::Error;

#[derive(Error, Debug)]
pub enum CliError {
    #[error("generic error: {0}")]
    Generic(String),
    #[error("invalid argument: {0}")]
    Usage(String),
    #[error("conflict without --force: {path}")]
    Conflict { path: String },
    #[error("I/O error at {path}: {source}")]
    Io {
        path: String,
        #[source]
        source: std::io::Error,
    },
    #[error("drift detected in strict mode")]
    DriftStrict,
    #[error("manifest missing or corrupted")]
    ManifestMissing,
    #[error("failed to parse configuration: {0}")]
    ConfigParse(String),
    #[error("interrupted by SIGINT")]
    Sigint,
}

impl CliError {
    pub fn exit_code(&self) -> i32 {
        match self {
            CliError::Generic(_) => 1,
            CliError::Usage(_) => 2,
            CliError::Conflict { .. } => 3,
            CliError::Io { .. } => 4,
            CliError::DriftStrict => 5,
            CliError::ManifestMissing => 6,
            CliError::ConfigParse(_) => 7,
            CliError::Sigint => 130,
        }
    }

    pub fn io(path: impl Into<String>, source: std::io::Error) -> Self {
        CliError::Io {
            path: path.into(),
            source,
        }
    }
}