Adify v0.1.0 Adify.Tool

Represents a Tool that can be installed/uninstalled using Adify

Link to this section Summary

Functions

Installs a tool based on a given strategy

Uninstalls a tool based on a given strategy

Link to this section Types

Link to this type

t()
t() :: %Adify.Tool{
  description: term(),
  name: term(),
  os_commands: term(),
  version: term()
}

Link to this section Functions

Link to this function

changeset(struct, params)

Link to this function

install(tool, os, strategy \\ :default)
install(Adify.Tool.t(), String.t(), integer() | :default) ::
  {:ok, term()} | {:error, term()}

Installs a tool based on a given strategy

Examples:

# When all inputs are valid
iex> {:ok, tool} =
...>   Adify.YAML.parse_and_cast("./test/support/tools/valid/201907051629/tool.yaml")
iex> {:ok, output} = Adify.Tool.install(tool, "arch_linux")
iex> output =~ "Running Pre:" && output =~ "hello pre" &&
...>   output =~ "Running Main:" && output =~ "hello main" &&
...>   output =~ "Running Post:" && output =~ "hello post"
true

# When OS isn't valid
iex> {:ok, tool} =
...>   Adify.YAML.parse_and_cast("./test/support/tools/valid/201907051629/tool.yaml")
iex> Adify.Tool.install(tool, "redox")
{:error, "Invalid OS"}
Link to this function

uninstall(tool, os, strategy \\ :default)
uninstall(Adify.Tool.t(), String.t(), integer() | :default) ::
  {:ok, term()} | {:error, term()}

Uninstalls a tool based on a given strategy

Examples:

# When all inputs are valid
iex> {:ok, tool} =
...>   Adify.YAML.parse_and_cast("./test/support/tools/valid/201907051629/tool.yaml")
iex> {:ok, output} = Adify.Tool.uninstall(tool, "arch_linux")
iex> output =~ "Running Pre:" && output =~ "bye pre" &&
...>   output =~ "Running Main:" && output =~ "bye main" &&
...>   output =~ "Running Post:" && output =~ "bye post"
true

# When OS isn't valid
iex> {:ok, tool} =
...>   Adify.YAML.parse_and_cast("./test/support/tools/valid/201907051629/tool.yaml")
iex> Adify.Tool.uninstall(tool, "redox")
{:error, "Invalid OS"}