angular-switcher 0.1.0

Switch between Angular component files (.ts, .html, styles, .spec.ts) from the Zed editor with a customizable keybinding.
Documentation
use std::path::PathBuf;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum SwitcherError {
    #[error("invalid input: {0}")]
    Input(String),

    #[error("no sibling found{}", match target {
        Some(t) => format!(" for target '{t}'"),
        None => String::new(),
    })]
    NoSibling { target: Option<String> },

    #[error("config error: {0}")]
    Config(String),

    #[error("io error reading {path}: {source}")]
    Io {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    #[error("failed to launch `zed`: {0}. Is the Zed CLI on your PATH? See https://zed.dev/docs/getting-started")]
    LaunchFailed(String),
}

impl SwitcherError {
    pub fn exit_code(&self) -> i32 {
        match self {
            Self::Input(_) | Self::Io { .. } | Self::LaunchFailed(_) => 1,
            Self::NoSibling { .. } => 2,
            Self::Config(_) => 3,
        }
    }
}