Created
May 15, 2015 21:03
-
-
Save mbroadhead/45f7480e7016c0578240 to your computer and use it in GitHub Desktop.
Various ways of calling a task (run_task, do_task, function)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Rex -base; | |
use feature qw(say); | |
task "call_me_with_do_task" => sub { | |
say 'inside task: "call_me_with_do_task"'; | |
}; | |
before_task_start "call_me_with_do_task" => sub { | |
say 'inside before_task_start hook for task: "call_me_with_do_task"'; | |
}; | |
after_task_finished "call_me_with_do_task" => sub { | |
say 'inside after_task_finished hook for task: "call_me_with_do_task"'; | |
}; | |
task "call_me_with_run_task" => sub { | |
say 'inside task: "call_me_with_run_task"'; | |
}; | |
before_task_start "call_me_with_run_task" => sub { | |
say 'inside before_task_start hook for task: "call_me_with_run_task"'; | |
}; | |
after_task_finished "call_me_with_run_task" => sub { | |
say 'inside after_task_finished hook for task: "call_me_with_run_task"'; | |
}; | |
task "call_me_as_a_function" => sub { | |
say 'inside task: "call_me_as_a_function"'; | |
}; | |
before_task_start "call_me_as_a_function" => sub { | |
say 'inside before_task_start hook for task: "call_me_as_a_function"'; | |
}; | |
after_task_finished "call_me_as_a_function" => sub { | |
say 'inside after_task_finished hook for task: "call_me_as_a_function"'; | |
}; | |
task "init" => sub { | |
do_task "call_me_with_do_task"; | |
run_task "call_me_with_run_task"; | |
call_me_as_a_function(); | |
}; | |
1; | |
__END__ | |
# Output | |
$ rex init | |
[2015-05-15 13:42:11] INFO - Running task init on <local> | |
inside before_task_start hook for task: "call_me_with_do_task" | |
[2015-05-15 13:42:12] INFO - Running task call_me_with_do_task on <local> | |
inside task: "call_me_with_do_task" | |
inside after_task_finished hook for task: "call_me_with_do_task" | |
inside task: "call_me_with_run_task" | |
[2015-05-15 13:42:12] INFO - Running task call_me_as_a_function on current connection | |
inside task: "call_me_as_a_function" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment