mod docker;
mod go;
mod preset_detector;
mod python;
mod registry;
mod rust;
use crate::error::Result;
use std::collections::HashMap;
use std::path::Path;
#[derive(Debug, Clone, PartialEq)]
pub struct DetectionResult {
pub project_type: ProjectType,
pub language_version: Option<String>,
pub metadata: HashMap<String, String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ProjectType {
RustLibrary,
RustBinary,
RustWorkspace,
PythonApp,
PythonLibrary,
GoApp,
GoLibrary,
DockerImage,
}
impl std::fmt::Display for ProjectType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ProjectType::RustLibrary => write!(f, "Rust Library"),
ProjectType::RustBinary => write!(f, "Rust Binary"),
ProjectType::RustWorkspace => write!(f, "Rust Workspace"),
ProjectType::PythonApp => write!(f, "Python Application"),
ProjectType::PythonLibrary => write!(f, "Python Library"),
ProjectType::GoApp => write!(f, "Go Application"),
ProjectType::GoLibrary => write!(f, "Go Library"),
ProjectType::DockerImage => write!(f, "Docker Image"),
}
}
}
pub trait ProjectDetector: Send + Sync {
fn detect(&self, path: &Path) -> Result<Option<DetectionResult>>;
fn name(&self) -> &str;
}
pub use docker::DockerDetector;
pub use go::GoDetector;
pub use preset_detector::PresetDetector;
pub use python::PythonDetector;
pub use registry::DetectorRegistry;
pub use rust::RustDetector;