Current section
Files
Jump to
Current section
Files
lib/mix/tasks/up.ex
defmodule Mix.Tasks.Eise.Up do
@moduledoc """
Handles all installation and updates
"""
use Mix.Task
import Eisegesis.Executor
alias Eisegesis.Output
alias Eisegesis.Passenger.{Asdf, Yarn, Homebrew, Shell, Dotfiles, Repos}
def run(_) do
with path <- get_path_for("setup.toml"),
{:ok, _stat} <- File.stat(path),
{:ok, options} <- Toml.decode_file(path),
:ok <- start_section("WELCOME TO EISEGENIS!") do
options
|> Task.async_stream(&each_module/1)
|> Enum.into([])
else
{:error, error} ->
Output.error(
"Error while trying to initialize `eisegesis`\nRecheck your `setup.toml` file",
error
)
end
end
defp each_module({"asdf" = passenger, opts}), do: Asdf.up(passenger, opts)
defp each_module({"yarn" = passenger, opts}), do: Yarn.up(passenger, opts)
defp each_module({"homebrew" = passenger, opts}), do: Homebrew.up(passenger, opts)
defp each_module({"dotfiles" = passenger, opts}), do: Dotfiles.up(passenger, opts)
defp each_module({"repos" = passenger, opts}), do: Repos.up(passenger, opts)
defp each_module({"shell" = passenger, opts}), do: Shell.up(passenger, opts)
defp each_module(_),
do: Output.error("There's a error on your `setup.toml` file", "unable to parse `setup.toml`")
end