Packages

create real CLIs in elixir, using mix tasks

Current section

Files

Jump to
meld lib util.ex
Raw

lib/util.ex

defmodule Meld.Util do
@moduledoc """
Exposes some helpful functions to the rest of the codebase.
"""
@doc """
Checks if the ~/.meld directory exists.
"""
def check_dir_exists(ifnot) do
if File.exists? path do
raise ifnot
exit ""
end
end
@doc """
Checks if the ~/.meld directory DOESN'T exist.
"""
def check_dir_not_exists(ifnot) do
if !File.exists? path do
raise ifnot
exit ""
end
end
@doc """
Creates the ~/.meld directory.
"""
def create_dir do
path
|> File.mkdir_p!
end
@doc """
Returns the full ~/.meld path.
"""
def path, do: Path.expand "~/.meld"
end