Mate.Helpers (Mate v0.1.5) View Source

This module contains helper functions that can be used to execute commands on the local machine, or the remote machine using the configured driver ƒrom .mate.exs. It also have functions to copy files from or to the remote server.

These helpers are automatically imported in a custom Mate.Pipeline.Step.

For example:

  defmodule CustomHelloUser do
    use Mate.Pipeline.Step

    @impl true
    def run(session) do
      {:ok, user} = remote_cmd(session, "whoami")
      IO.puts "Hello " <> user
      {:ok, session}
    end
  end

Link to this section Summary

Functions

Safely terminate connections and raises error

Copy a file from the remote server to the local machine

Copy a file from your local machine to the remote server

Execute a command (with arguments) on the local machine

Execute a script on the local machine

Execute a command (with arguments) on the remote machine

Execute a script on the remote machine

Link to this section Functions

Link to this function

bail(session, message, error \\ "")

View Source

Specs

bail(session :: Mate.Session.t(), message :: String.t(), error :: String.t()) ::
  no_return()

Safely terminate connections and raises error

Link to this function

copy_from(session, src, dest)

View Source

Specs

copy_from(session :: Mate.Session.t(), src :: String.t(), dest :: String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Copy a file from the remote server to the local machine

Link to this function

copy_to(session, src, dest)

View Source

Specs

copy_to(session :: Mate.Session.t(), src :: String.t(), dest :: String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Copy a file from your local machine to the remote server

Link to this function

local_cmd(session, cmd, args \\ [])

View Source

Specs

local_cmd(
  session :: Mate.Session.t(),
  command :: String.t(),
  args :: [String.t()]
) :: {:ok, String.t()} | {:error, String.t()}

Execute a command (with arguments) on the local machine

Link to this function

local_script(session, script)

View Source

Specs

local_script(session :: Mate.Session.t(), script :: String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Execute a script on the local machine

Link to this function

remote_cmd(session, cmd, args \\ [])

View Source

Specs

remote_cmd(session :: Mate.Session.t(), cmd :: String.t(), args :: [String.t()]) ::
  {:ok, String.t()} | {:error, String.t()}

Execute a command (with arguments) on the remote machine

Link to this function

remote_script(session, script)

View Source

Specs

remote_script(session :: Mate.Session.t(), script :: String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Execute a script on the remote machine