Adify v0.1.0 Adify.Tool.InstallationStrategy.Workflow.Op

Representation around a command, expected output and success

Link to this section Summary

Link to this section Types

Link to this type

t()
t() :: %Adify.Tool.InstallationStrategy.Workflow.Op{
  command: term(),
  expected: term(),
  success: term()
}

Link to this section Functions

Link to this function

changeset(struct, params)

Link to this function

run(operation)
run(Adify.Tool.InstallationStrategy.Workflow.Op.t()) ::
  {:ok, term()} | {:error, term()}

Runs an operation

Examples:

# When success is true
iex> operation = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: true,
...>   expected: ".*"
...> }
iex> Adify.Tool.InstallationStrategy.Workflow.Op.run(operation)
{:ok, "hi\n"}

# When success is true
iex> operation = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: true,
...>   expected: "bad"
...> }
iex> Adify.Tool.InstallationStrategy.Workflow.Op.run(operation)
{:error, "Expression didn't match:\nExpected: bad:\nGot: hi\n\n"}

# When regex is bad
iex> operation = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: true,
...>   expected: "*"
...> }
iex> Adify.Tool.InstallationStrategy.Workflow.Op.run(operation)
{:error, {'nothing to repeat', 0}}

# When success is false
iex> operation = %Adify.Tool.InstallationStrategy.Workflow.Op{
...>   command: "echo hi",
...>   success: false,
...>   expected: ".*"
...> }
iex> Adify.Tool.InstallationStrategy.Workflow.Op.run(operation)
{:error, "hi\n"}