View Source Tux.Exec behaviour (Tux v0.4.0)

Dispatcher subystem for invoking command modules, with optional rescuing from raised exceptions.

This module is injected in dispatcher at call site:

...
use Tux.Exec, overrideable: true
...

Of course, the injected exec/2 function can be overwritten in your dispatchers:

defmodule MyDispatcher do
  use Tux.Dispatcher

  @impl true
  def exec(env, exec_opts) do
    ... implement custom command module execution here
  end
end

Summary

Types

The Tux.Env constructed by dispatcher for an invoked command.

Execution options for command module.

Callbacks

Invoke the command module according to the information in the env and return the result, with optional recovery from exceptions.

Functions

Inject the exec/2 function.

Types

env()

@type env() :: Tux.Env.t()

The Tux.Env constructed by dispatcher for an invoked command.

exec_opts()

@type exec_opts() :: [{:rescue, boolean()}]

Execution options for command module.

Callbacks

exec(env, exec_opts)

@callback exec(env(), exec_opts()) :: Tux.Result.t()

Invoke the command module according to the information in the env and return the result, with optional recovery from exceptions.

Functions

__using__(opts \\ [])

(macro)

Inject the exec/2 function.