use std::path::PathBuf;
use alba_syntax::{Span, Spanned, StringTemplate};
use crate::eval::Scope;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct SourceId(pub usize);
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BeamId(pub String);
#[derive(Debug, Clone, PartialEq)]
pub enum ExecutorKind {
Shell,
SystemShell,
Docker {
image: String,
volumes: Vec<String>,
workdir: Option<String>,
},
Plugin {
name: String,
options: Vec<(String, OptionValue)>,
},
}
#[derive(Debug, Clone, PartialEq)]
pub enum OptionValue {
Str(String),
Bool(bool),
List(Vec<String>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum Value {
Str(String),
Bool(bool),
}
impl Value {
pub(crate) fn type_name(&self) -> &'static str {
match self {
Value::Str(_) => "a string",
Value::Bool(_) => "a boolean",
}
}
pub(crate) fn as_display(&self) -> &str {
match self {
Value::Str(s) => s.as_str(),
Value::Bool(true) => "true",
Value::Bool(false) => "false",
}
}
}
#[derive(Debug, Clone)]
pub struct Beam {
pub id: BeamId,
pub description: Option<String>,
pub needs: Vec<Spanned<BeamId>>,
pub params: Vec<String>,
pub inputs: Vec<String>,
pub outputs: Vec<String>,
pub run: Vec<StringTemplate>,
pub env: Vec<(String, StringTemplate)>,
pub cwd: Option<String>,
pub executor: ExecutorKind,
pub allow_failure: bool,
pub dir: PathBuf,
pub span: Span,
pub source: SourceId,
pub scope: Scope,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Hook {
pub name: String,
pub beam: Spanned<BeamId>,
pub arity: usize,
pub span: Span,
pub source: SourceId,
}
#[derive(Debug, Clone)]
pub struct Project {
pub beams: Vec<Beam>,
pub default: Option<Spanned<BeamId>>,
pub hooks: Vec<Hook>,
}