use super::*;
#[derive(Default)]
pub struct ForTaskDefinitionBuilder {
task: ForTaskDefinition,
}
impl ForTaskDefinitionBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn each(&mut self, each: &str) -> &mut Self {
self.task.for_.each = each.to_string();
self
}
pub fn in_(&mut self, in_: &str) -> &mut Self {
self.task.for_.in_ = in_.to_string();
self
}
pub fn at(&mut self, at: &str) -> &mut Self {
self.task.for_.at = Some(at.to_string());
self
}
pub fn do_<F>(&mut self, name: &str, setup: F) -> &mut Self
where
F: FnOnce(&mut TaskDefinitionBuilder),
{
let mut builder = TaskDefinitionBuilder::new();
setup(&mut builder);
let task = builder.build();
self.task.do_.add(name.to_string(), task);
self
}
pub fn while_(&mut self, while_expr: &str) -> &mut Self {
self.task.while_ = Some(while_expr.to_string());
self
}
}
impl_task_definition_builder_base!(ForTaskDefinitionBuilder, task, TaskDefinition::For);