use std::path::{Path, PathBuf};
pub trait Detector: Sync {
fn detect(&self, root: &Path) -> Option<Finding>;
}
#[derive(Debug, Clone)]
pub struct Finding {
pub ecosystem: &'static str,
#[allow(dead_code)]
pub tool: Option<String>,
pub fragments: Vec<Fragment>,
pub notes: Vec<String>,
}
#[derive(Debug, Clone)]
pub enum Fragment {
Runtime {
backend: &'static str,
default_service: Option<String>,
compose_passthrough: bool,
service_passthrough: bool,
},
Devcontainer { path: PathBuf },
EnvFile(String),
Command(CommandFragment),
}
#[derive(Debug, Clone)]
pub struct CommandFragment {
pub name: String,
pub desc: String,
pub run: RunSpec,
pub in_service: Option<String>,
pub tty: Option<bool>,
pub forward_args: Option<bool>,
pub needs: Vec<String>,
}
#[derive(Debug, Clone)]
pub enum RunSpec {
Single(String),
Steps(Vec<String>),
}
impl CommandFragment {
pub fn shell(name: impl Into<String>, desc: impl Into<String>, run: impl Into<String>) -> Self {
Self {
name: name.into(),
desc: desc.into(),
run: RunSpec::Single(run.into()),
in_service: None,
tty: None,
forward_args: None,
needs: Vec::new(),
}
}
pub fn with_forward_args(mut self) -> Self {
self.forward_args = Some(true);
self
}
pub fn with_tty(mut self) -> Self {
self.tty = Some(true);
self
}
}