Implement nested tasks

This commit is contained in:
Thibault Jouan
2014-09-24 22:26:22 +00:00
parent ede9ea7111
commit 638f8320bc
5 changed files with 48 additions and 6 deletions

View File

@@ -43,6 +43,10 @@ module Producer
@condition
end
def task(name, *args, &block)
@actions << self.class.evaluate(@env, name, *args, &block)
end
def ask(question, choices, prompter: Prompter.new(@env.input, @env.output))
prompter.prompt(question, choices)
end

View File

@@ -18,8 +18,12 @@ module Producer
if task.condition_met?
@env.log "Task: `#{task}' applying..."
task.actions.each do |e|
@env.log " action: #{e}"
e.apply unless @env.dry_run?
case e
when Task then process_task e
else
@env.log " action: #{e}"
e.apply unless @env.dry_run?
end
end
else
@env.log "Task: `#{task}' skipped"