deli v0.2.0-rc.6 Deli.Command behaviour View Source

Run commands locally or remotely.

Defines a behaviour that application commands should implement.

Provides conveniences to use these commands.

Example

# lib/mix/tasks/my_app/my_app.xyz.ex
defmodule Mix.Tasks.MyApp.XYZ do
  use Mix.Task

  def run(args) do
    Deli.Command.run(MyApp.Commands.XYZ, args)
  end
end

# lib/my_app/commands/my_command.ex
defmodule MyApp.Commands.XYZ do
  @behaviour Deli.Command

  @impl true
  def run(args) do
    # do actual work
  end
end

# executes locally by default
$ mix my_app.xyz --arg_example=1

# runs command in all prod hosts
$ mix my_app.xyz --arg_example=1 -t prod

# runs command in all prod hosts that match ~r/01/
$ mix my_app.xyz --arg_example=1 -t prod -h 01

Link to this section Summary

Functions

Either runs a command locally (dev), or through a RPC call to the remote target env

Fetches env from target (specified or default), and runs call/3

Link to this section Functions

Either runs a command locally (dev), or through a RPC call to the remote target env

Fetches env from target (specified or default), and runs call/3

Link to this section Callbacks