use thiserror::Error;
pub type CliResult<T> = Result<T, CliError>;
#[derive(Error, Debug)]
#[allow(dead_code)]
pub enum CliError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Template error: {0}")]
Template(String),
#[error("Invalid project name: {0}")]
InvalidProjectName(String),
#[error("Template not found: {0}")]
TemplateNotFound(String),
#[error("Invalid backend: {0}")]
InvalidBackend(String),
#[error("Code generation failed: {0}")]
CodegenError(String),
#[error("Parse error: {0}")]
ParseError(String),
#[error("Project already exists at: {0}")]
ProjectExists(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("Validation failed: {0}")]
Validation(String),
#[error("Feature not available: {0}. Enable with --features {1}")]
FeatureNotAvailable(String, String),
}
impl From<handlebars::RenderError> for CliError {
fn from(e: handlebars::RenderError) -> Self {
CliError::Template(e.to_string())
}
}
impl From<handlebars::TemplateError> for CliError {
fn from(e: handlebars::TemplateError) -> Self {
CliError::Template(e.to_string())
}
}
impl From<toml::de::Error> for CliError {
fn from(e: toml::de::Error) -> Self {
CliError::Config(e.to_string())
}
}
impl From<toml::ser::Error> for CliError {
fn from(e: toml::ser::Error) -> Self {
CliError::Config(e.to_string())
}
}
impl From<syn::Error> for CliError {
fn from(e: syn::Error) -> Self {
CliError::ParseError(e.to_string())
}
}