WeareJH / wf2

PHP environments for Magento 1, Magento 2 & Wordpress
6 stars 3 forks source link

mvp of conditional tasks #54

Closed shakyShane closed 4 years ago

shakyShane commented 4 years ago

adds conditional task type - for example:

here all conditions must be met with Answer:Yes (either in code or by user input) - if all conditions are met then the second vec of tasks will be executed.

Task::conditional(
    vec![
        Box::new(FilePresent::new(left_abs.clone())),
        Box::new(FilePresent::new(right_abs.clone())),
        Box::new(FilesDiffer::new(left_abs.clone(), right_abs.clone())),
        Box::new(Question::new(question)),
    ],
    vec![
        Task::file_clone(right_abs, left_abs),
        Task::notify(format!("{}: Copied {} to {}", prefix, Cyan.paint(RIGHT), Cyan.paint(LEFT))),
        Task::notify(format!("{}", warning)),
    ],
)