use crate::expr::Expr;
use crate::template::StringTemplate;
use crate::token::Span;
#[derive(Debug, Clone, PartialEq)]
pub struct Spanned<T> {
pub value: T,
pub span: Span,
}
impl<T> Spanned<T> {
pub fn new(value: T, span: Span) -> Self {
Self { value, span }
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct File {
pub version: Option<Spanned<String>>,
pub imports: Vec<Import>,
pub lets: Vec<LetBinding>,
pub default: Option<Spanned<String>>,
pub beams: Vec<BeamDecl>,
pub hooks: Vec<HookDecl>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Import {
pub path: Spanned<String>,
pub alias: Spanned<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct LetBinding {
pub name: Spanned<String>,
pub value: Expr,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BeamRef {
pub namespace: Vec<String>,
pub name: String,
}
pub type NamedString = (Spanned<String>, StringTemplate);
#[derive(Debug, Clone, PartialEq)]
pub enum ExecutorOptionValue {
Str(StringTemplate),
Bool(bool),
List(Vec<StringTemplate>),
}
#[derive(Debug, Clone, PartialEq)]
pub struct ExecutorDecl {
pub name: Spanned<String>,
pub options: Vec<(Spanned<String>, ExecutorOptionValue)>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct BeamDecl {
pub name: Spanned<String>,
pub params: Vec<Spanned<String>>,
pub description: Option<StringTemplate>,
pub needs: Vec<Spanned<BeamRef>>,
pub inputs: Vec<StringTemplate>,
pub outputs: Vec<StringTemplate>,
pub run: Vec<StringTemplate>,
pub env: Vec<NamedString>,
pub cwd: Option<StringTemplate>,
pub executor: Option<ExecutorDecl>,
pub allow_failure: bool,
pub span: Span,
}
#[derive(Debug, Clone, PartialEq)]
pub struct HookDecl {
pub name: Spanned<String>,
pub beam: Spanned<BeamRef>,
pub span: Span,
}