Packages

A collection of tasks that help you install, update and teardown package managers and other things useful for your dotfiles. It's something like a meta package manager (package manager is the wrong word... still searching for a better one).

Current section

Files

Jump to
eisegesis lib mix tasks up.ex
Raw

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
@passengers ["dotfiles", "repos", "yarn", "homebrew", "asdf", "shell"]
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(&parse_opts/1)
|> Enum.into([])
else
{:error, error} ->
Output.error(
"Error while trying to initialize `eisegesis`\nRecheck your `setup.toml` file",
error
)
end
end
defp parse_opts({passenger, opts}) when passenger in @passengers do
module =
["elixir", "eisegesis", "passenger", passenger]
|> Enum.map(&String.capitalize/1)
|> Enum.join(".")
|> String.to_atom()
apply(module, :up, [opts])
end
defp parse_opts(_),
do: Output.error("There's a error on your `setup.toml` file", "unable to parse `setup.toml`")
end