Credo v1.2.0 Credo.Execution.ProcessDefinition View Source
A ProcessDefinition
can be used to define a process which consists of
several tasks and can be called with a Credo.Execution
struct.
defmodule Credo.ExampleProcess do
use Credo.Execution.ProcessDefinition
run Credo.Task.ParseOptions
run Credo.Task.ValidateOptions
run Credo.Task.RunCommand
run Credo.Task.AssignExitStatus
end
All modules registered with run/1
will be executed in order when the process is called (a bit like a Plug pipeline):
argv = ["command", "line", "--arguments"]
exec = Credo.Execution.build(argv)
Credo.ExampleProcess.call(exec)
For convenience, tasks belonging together semantically can be grouped using actvity/2
:
defmodule Credo.ExampleProcess do
use Credo.Execution.ProcessDefinition
activity :prepare_analysis do
run Credo.Task.ParseOptions
run Credo.Task.ValidateOptions
end
activity :run_analysis do
run Credo.Task.RunCommand
run Credo.Task.AssignExitStatus
end
end
Each task receives an Execution struct and returns an Execution struct upon completion. Any Task can mark the Execution as “halted” to stop Credo’s execution. Subsequent Tasks won’t be run in this case.
Link to this section Summary
Functions
Creates a group of tasks (an “activity”) with the given name
Registers a Task module with the current process
Link to this section Functions
Creates a group of tasks (an “activity”) with the given name
.
Activities are called in order when the surrounding process is called.
Registers a Task module with the current process.
Tasks are called in order when the surrounding process or activity is called.